diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_DeleteSubscriptionPlan.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_DeleteSubscriptionPlan.sql index 57df976..fde68ea 100644 --- a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_DeleteSubscriptionPlan.sql +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_DeleteSubscriptionPlan.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetEditions.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetEditions.sql new file mode 100644 index 0000000..d501b25 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetEditions.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseById.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseById.sql new file mode 100644 index 0000000..a3379c9 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseById.sql @@ -0,0 +1,74 @@ +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetLicenseById]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetLicenseById] +GO +-- ==================================================== +-- Author: Magic Software +-- Create date: 29-Jan-2018 +-- Description: To get a license information on the basis of LicenseId +-- ==================================================== +create PROCEDURE [dbo].[usp_GetLicenseById] + -- Add the parameters for the stored procedure here + @Id int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + declare @SubscriptionStartDate datetime, @SubscriptionEndDate datetime, @NoOfImages int, @TotalAmount money, @RenewalDate datetime, + @SiteIp varchar(100), @SiteIpTo varchar(100), @SiteMasterIPTo varchar(100); + declare @UserId int, @Login varchar(100), @Password varchar(100), @SecurityQuestionId int, @Answer varchar(100); + declare @EditionId int, @TotalLogins int; + declare @EditionLoginText varchar(1000); + + declare CurEditionLogin cursor for + select EditionId, TotalLogins from LicenseToEdition where LicenseId = @Id; + + set @EditionLoginText = ''; + open CurEditionLogin + fetch NEXT FROM CurEditionLogin into @EditionId, @TotalLogins + while @@FETCH_STATUS = 0 + begin + set @EditionLoginText = @EditionLoginText + convert(varchar(5), @EditionId) + '-' + convert(varchar(5), @TotalLogins) + '|'; + fetch NEXT FROM CurEditionLogin into @EditionId, @TotalLogins + end + CLOSE CurEditionLogin + DEALLOCATE CurEditionLogin + set @EditionLoginText = SUBSTRING(@EditionLoginText, 1, len(@EditionLoginText) - 1); + + select top 1 + @SubscriptionStartDate = LSD.SubscriptionValidFrom, + @SubscriptionEndDate = LSD.SubscriptionValidThrough, + @RenewalDate = LSD.RenewalDate, + @NoOfImages = LSD.NoofImages, + @TotalAmount = LSD.TotalAmount + from LicenseSubscriptionDetail LSD where LSD.LicenseId = @Id order by LSD.Id desc; + + select top 1 @SiteIp = S.SiteIP, @SiteIpTo = S.SiteIPTo, @SiteMasterIPTo = S.SiteMasterIPTo from Site S + inner join SiteToLicenseEdition SLE ON S.Id = SLE.SiteId + inner join LicenseToEdition LE on SLE.LicenseEditionId = LE.Id + where LE.LicenseId = @Id and S.IsMaster = 1 AND S.IsActive = 1 order by SLE.SiteId desc; + + select top 1 @UserId = US.Id, @Login = US.LoginId, @Password = US.Password, @SecurityQuestionId = US.SecurityQuestionId, + @Answer = US.SecurityAnswer from AIAUserToLicenseEdition UL inner join LicenseToEdition LE on UL.LicenseEditionId = LE.Id + inner join AIAUser US on UL.UserId = US.Id where LE.LicenseId = @Id order by LE.Id desc; + + select L.Id, L.LicenseTypeId, L.AccountNumber, L.AccountTypeId, L.Address1, L.Address2, L.LicenseeFirstName, L.LicenseeLastName, L.City, + L.CountryId, L.StateId, L.EmailId, L.InstitutionName, L.Phone, L.ProductId, L.Zip, L.TotalLogins, @EditionLoginText as EditionLogins, + @SubscriptionStartDate as SubscriptionStartDate, @SubscriptionEndDate as SubscriptionEndDate, @NoOfImages as NoOfImages, @TotalAmount as Price, + @SiteIp as SiteUrl, @SiteIpTo as SitToUrl, @SiteMasterIPTo as SiteMasterUrl, @UserId as UserId, @Login as Login, @Password as Password, + @SecurityQuestionId as SecurityQuestionId, @Answer as Answer, L.NoOfRenewals as TotalRenewals, @RenewalDate as RenewalDate, L.IsActive + from License L where L.Id = @Id; + +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO \ No newline at end of file diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseTypes.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseTypes.sql new file mode 100644 index 0000000..4621556 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseTypes.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenses.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenses.sql new file mode 100644 index 0000000..051b8c5 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenses.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql index c7ec30d..083cb42 100644 --- a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql index 7bec445..ae4f426 100644 --- a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql index 0540a18..e502a7c 100644 --- a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj b/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj index 59285cf..77d6a81 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj @@ -135,6 +135,7 @@ + @@ -156,14 +157,13 @@ - + + - - - - - + + + @@ -716,6 +716,21 @@ AIADBEntity.tt + + AIADBEntity.tt + + + AIADBEntity.tt + + + AIADBEntity.tt + + + AIADBEntity.tt + + + AIADBEntity.tt + AIADBEntity.tt @@ -755,6 +770,10 @@ Global.asax + + + + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AccountController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AccountController.cs index 4efd5ab..9980a27 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AccountController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AccountController.cs @@ -1,494 +1,43 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Net; using System.Net.Http; -using System.Security.Claims; -using System.Security.Cryptography; -using System.Threading.Tasks; -using System.Web; using System.Web.Http; -using System.Web.Http.ModelBinding; -using Microsoft.AspNet.Identity; -using Microsoft.AspNet.Identity.EntityFramework; -using Microsoft.AspNet.Identity.Owin; -using Microsoft.Owin.Security; -using Microsoft.Owin.Security.Cookies; -using Microsoft.Owin.Security.OAuth; -using AIAHTML5.Server.Models; -using AIAHTML5.Server.Providers; -using AIAHTML5.Server.Results; - -namespace AIAHTML5.Server.Controllers +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using AIAHTML5.ADMIN.API.Models; +using System.Web.Http.Cors; +using System.Web.Cors; +using AIAHTML5.Server.Constants; +using log4net; +using System.Text; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Controllers { - [Authorize] - [RoutePrefix("api/Account")] + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + [RoutePrefix("Account")] public class AccountController : ApiController { - private const string LocalLoginProvider = "Local"; - private ApplicationUserManager _userManager; - - public AccountController() - { - } - - public AccountController(ApplicationUserManager userManager, - ISecureDataFormat accessTokenFormat) - { - UserManager = userManager; - AccessTokenFormat = accessTokenFormat; - } - - public ApplicationUserManager UserManager - { - get - { - return _userManager ?? Request.GetOwinContext().GetUserManager(); - } - private set - { - _userManager = value; - } - } - - public ISecureDataFormat AccessTokenFormat { get; private set; } - - // GET api/Account/UserInfo - [HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)] - [Route("UserInfo")] - public UserInfoViewModel GetUserInfo() - { - ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity); - - return new UserInfoViewModel - { - Email = User.Identity.GetUserName(), - HasRegistered = externalLogin == null, - LoginProvider = externalLogin != null ? externalLogin.LoginProvider : null - }; - } - - // POST api/Account/Logout - [Route("Logout")] - public IHttpActionResult Logout() - { - Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType); - return Ok(); - } - - // GET api/Account/ManageInfo?returnUrl=%2F&generateState=true - [Route("ManageInfo")] - public async Task GetManageInfo(string returnUrl, bool generateState = false) - { - IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); - - if (user == null) - { - return null; - } - - List logins = new List(); - - foreach (IdentityUserLogin linkedAccount in user.Logins) - { - logins.Add(new UserLoginInfoViewModel - { - LoginProvider = linkedAccount.LoginProvider, - ProviderKey = linkedAccount.ProviderKey - }); - } - - if (user.PasswordHash != null) - { - logins.Add(new UserLoginInfoViewModel - { - LoginProvider = LocalLoginProvider, - ProviderKey = user.UserName, - }); - } - - return new ManageInfoViewModel - { - LocalLoginProvider = LocalLoginProvider, - Email = user.UserName, - Logins = logins, - ExternalLoginProviders = GetExternalLogins(returnUrl, generateState) - }; - } - - // POST api/Account/ChangePassword - [Route("ChangePassword")] - public async Task ChangePassword(ChangePasswordBindingModel model) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, - model.NewPassword); - - if (!result.Succeeded) - { - return GetErrorResult(result); - } - - return Ok(); - } - - // POST api/Account/SetPassword - [Route("SetPassword")] - public async Task SetPassword(SetPasswordBindingModel model) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword); - - if (!result.Succeeded) - { - return GetErrorResult(result); - } - - return Ok(); - } - - // POST api/Account/AddExternalLogin - [Route("AddExternalLogin")] - public async Task AddExternalLogin(AddExternalLoginBindingModel model) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie); - - AuthenticationTicket ticket = AccessTokenFormat.Unprotect(model.ExternalAccessToken); - - if (ticket == null || ticket.Identity == null || (ticket.Properties != null - && ticket.Properties.ExpiresUtc.HasValue - && ticket.Properties.ExpiresUtc.Value < DateTimeOffset.UtcNow)) - { - return BadRequest("External login failure."); - } - - ExternalLoginData externalData = ExternalLoginData.FromIdentity(ticket.Identity); - - if (externalData == null) - { - return BadRequest("The external login is already associated with an account."); - } - - IdentityResult result = await UserManager.AddLoginAsync(User.Identity.GetUserId(), - new UserLoginInfo(externalData.LoginProvider, externalData.ProviderKey)); - - if (!result.Succeeded) - { - return GetErrorResult(result); - } - - return Ok(); - } - - // POST api/Account/RemoveLogin - [Route("RemoveLogin")] - public async Task RemoveLogin(RemoveLoginBindingModel model) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - IdentityResult result; - - if (model.LoginProvider == LocalLoginProvider) - { - result = await UserManager.RemovePasswordAsync(User.Identity.GetUserId()); - } - else - { - result = await UserManager.RemoveLoginAsync(User.Identity.GetUserId(), - new UserLoginInfo(model.LoginProvider, model.ProviderKey)); - } - - if (!result.Succeeded) - { - return GetErrorResult(result); - } - - return Ok(); - } - - // GET api/Account/ExternalLogin - [OverrideAuthentication] - [HostAuthentication(DefaultAuthenticationTypes.ExternalCookie)] - [AllowAnonymous] - [Route("ExternalLogin", Name = "ExternalLogin")] - public async Task GetExternalLogin(string provider, string error = null) - { - if (error != null) - { - return Redirect(Url.Content("~/") + "#error=" + Uri.EscapeDataString(error)); - } - - if (!User.Identity.IsAuthenticated) - { - return new ChallengeResult(provider, this); - } - - ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity); - - if (externalLogin == null) - { - return InternalServerError(); - } - - if (externalLogin.LoginProvider != provider) - { - Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie); - return new ChallengeResult(provider, this); - } - - ApplicationUser user = await UserManager.FindAsync(new UserLoginInfo(externalLogin.LoginProvider, - externalLogin.ProviderKey)); - - bool hasRegistered = user != null; - - if (hasRegistered) - { - Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie); - - ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(UserManager, - OAuthDefaults.AuthenticationType); - ClaimsIdentity cookieIdentity = await user.GenerateUserIdentityAsync(UserManager, - CookieAuthenticationDefaults.AuthenticationType); - - AuthenticationProperties properties = ApplicationOAuthProvider.CreateProperties(user.UserName); - Authentication.SignIn(properties, oAuthIdentity, cookieIdentity); - } - else - { - IEnumerable claims = externalLogin.GetClaims(); - ClaimsIdentity identity = new ClaimsIdentity(claims, OAuthDefaults.AuthenticationType); - Authentication.SignIn(identity); - } - - return Ok(); - } - - // GET api/Account/ExternalLogins?returnUrl=%2F&generateState=true - [AllowAnonymous] - [Route("ExternalLogins")] - public IEnumerable GetExternalLogins(string returnUrl, bool generateState = false) - { - IEnumerable descriptions = Authentication.GetExternalAuthenticationTypes(); - List logins = new List(); - - string state; - - if (generateState) - { - const int strengthInBits = 256; - state = RandomOAuthStateGenerator.Generate(strengthInBits); - } - else - { - state = null; - } - - foreach (AuthenticationDescription description in descriptions) - { - ExternalLoginViewModel login = new ExternalLoginViewModel - { - Name = description.Caption, - Url = Url.Route("ExternalLogin", new - { - provider = description.AuthenticationType, - response_type = "token", - client_id = Startup.PublicClientId, - redirect_uri = new Uri(Request.RequestUri, returnUrl).AbsoluteUri, - state = state - }), - State = state - }; - logins.Add(login); - } - - return logins; - } - - // POST api/Account/Register - [AllowAnonymous] - [Route("Register")] - public async Task Register(RegisterBindingModel model) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; - - IdentityResult result = await UserManager.CreateAsync(user, model.Password); - - if (!result.Succeeded) - { - return GetErrorResult(result); - } - - return Ok(); - } - - // POST api/Account/RegisterExternal - [OverrideAuthentication] - [HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)] - [Route("RegisterExternal")] - public async Task RegisterExternal(RegisterExternalBindingModel model) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - var info = await Authentication.GetExternalLoginInfoAsync(); - if (info == null) - { - return InternalServerError(); - } - - var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; - - IdentityResult result = await UserManager.CreateAsync(user); - if (!result.Succeeded) - { - return GetErrorResult(result); - } - - result = await UserManager.AddLoginAsync(user.Id, info.Login); - if (!result.Succeeded) - { - return GetErrorResult(result); - } - return Ok(); - } - - protected override void Dispose(bool disposing) - { - if (disposing && _userManager != null) - { - _userManager.Dispose(); - _userManager = null; - } - - base.Dispose(disposing); - } - - #region Helpers - - private IAuthenticationManager Authentication - { - get { return Request.GetOwinContext().Authentication; } - } - - private IHttpActionResult GetErrorResult(IdentityResult result) - { - if (result == null) - { - return InternalServerError(); - } + AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); - if (!result.Succeeded) - { - if (result.Errors != null) - { - foreach (string error in result.Errors) - { - ModelState.AddModelError("", error); - } - } - - if (ModelState.IsValid) - { - // No ModelState errors are available to send, so just return an empty BadRequest. - return BadRequest(); - } - - return BadRequest(ModelState); - } - - return null; - } - - private class ExternalLoginData + [Route("AccountTypes")] + [HttpGet] + public HttpResponseMessage GetAccountTypes() { - public string LoginProvider { get; set; } - public string ProviderKey { get; set; } - public string UserName { get; set; } - - public IList GetClaims() - { - IList claims = new List(); - claims.Add(new Claim(ClaimTypes.NameIdentifier, ProviderKey, null, LoginProvider)); - - if (UserName != null) - { - claims.Add(new Claim(ClaimTypes.Name, UserName, null, LoginProvider)); - } - - return claims; - } - - public static ExternalLoginData FromIdentity(ClaimsIdentity identity) + List AccountTypeList = new List(); + try { - if (identity == null) - { - return null; - } - - Claim providerKeyClaim = identity.FindFirst(ClaimTypes.NameIdentifier); - - if (providerKeyClaim == null || String.IsNullOrEmpty(providerKeyClaim.Issuer) - || String.IsNullOrEmpty(providerKeyClaim.Value)) - { - return null; - } - - if (providerKeyClaim.Issuer == ClaimsIdentity.DefaultIssuer) - { - return null; - } - - return new ExternalLoginData - { - LoginProvider = providerKeyClaim.Issuer, - ProviderKey = providerKeyClaim.Value, - UserName = identity.FindFirstValue(ClaimTypes.Name) - }; + AccountTypeList = AccountTypeEntityModel.GetActiveAccountTypes(dbContext); + return Request.CreateResponse(HttpStatusCode.OK, AccountTypeList); } - } - - private static class RandomOAuthStateGenerator - { - private static RandomNumberGenerator _random = new RNGCryptoServiceProvider(); - - public static string Generate(int strengthInBits) + catch (Exception ex) { - const int bitsPerByte = 8; - - if (strengthInBits % bitsPerByte != 0) - { - throw new ArgumentException("strengthInBits must be evenly divisible by 8.", "strengthInBits"); - } - - int strengthInBytes = strengthInBits / bitsPerByte; - - byte[] data = new byte[strengthInBytes]; - _random.GetBytes(data); - return HttpServerUtility.UrlTokenEncode(data); + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } } - #endregion } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AddLicenseController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AddLicenseController.cs index 10fac4c..a9eb780 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AddLicenseController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/AddLicenseController.cs @@ -14,7 +14,7 @@ using log4net; namespace AIAHTML5.Server.Controllers { - [EnableCors(origins: "http://localhost:92", headers: "*", methods: "*")] + //[EnableCors(origins: "http://localhost:92", headers: "*", methods: "*")] public class AddLicenseController : ApiController { // GET: api/AddLicense diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/CommonController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/CommonController.cs new file mode 100644 index 0000000..ce4ce68 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/CommonController.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using AIAHTML5.ADMIN.API.Models; +using System.Web.Http.Cors; +using System.Web.Cors; +using AIAHTML5.Server.Constants; +using log4net; +using System.Text; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Controllers +{ + + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + [RoutePrefix("Common")] + public class CommonController : ApiController + { + AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); + + [Route("Countries")] + [HttpGet] + public HttpResponseMessage GetCountries() + { + List CountryList = new List(); + try + { + CountryList = CountryModel.GetCountries(dbContext); + return Request.CreateResponse(HttpStatusCode.OK, CountryList); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("States")] + [HttpGet] + public HttpResponseMessage GetUsStates() + { + List StateList = new List(); + try + { + StateList = StateModel.GetUsStates(dbContext); + return Request.CreateResponse(HttpStatusCode.OK, StateList); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("SecurityQuestions")] + [HttpGet] + public HttpResponseMessage GetSecurityQuestions() + { + List SecurityQuestionList = new List(); + try + { + SecurityQuestionList = SecurityQuestionModel.GetSecurityQuestions(dbContext); + return Request.CreateResponse(HttpStatusCode.OK, SecurityQuestionList); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("GetEdition")] + [HttpGet] + public IHttpActionResult GetEdition() + { + dbContext.Configuration.ProxyCreationEnabled = false; + List lstEdition1 = new List(); + var lstEdition = dbContext.Editions.Where(e => e.IsActive == true).OrderBy(e => e.Priority).ToList(); + lstEdition1 = lstEdition.Select(l => new Edition { Id = l.Id, Title = l.Title }).ToList(); + //lstCountry1.Insert(0, new Country { Id = 0, CountryName = "All" }); + return Ok(lstEdition1); + } + [Route("GetDiscountCode")] + [HttpGet] + public IHttpActionResult GetDiscountCode() + { + dbContext.Configuration.ProxyCreationEnabled = false; + List lstDiscountCode1 = new List(); + string sStartDate = DateTime.MinValue.ToShortDateString(); + string sEndDate = DateTime.MaxValue.ToShortDateString(); + var lstDiscountCode = dbContext.GetDiscountCodes("", "", "").ToList(); + lstDiscountCode1 = lstDiscountCode.Select(l => new DiscountCodeModel { Id = l.Id, DiscountCode = l.DiscountCode }).ToList(); + return Ok(lstDiscountCode1); + } + + [Route("GetAccountType")] + [HttpGet] + public IHttpActionResult GetAccountType() + { + List AccountTypeList = new List(); + //try + //{ + AccountTypeList = AccountTypeModel.GetAccountTypes(dbContext); + return Ok(AccountTypeList); + //} + //catch (Exception ex) + //{ + // // Log exception code goes here + // //return ex.Message; + //} + } + protected HttpResponseMessage ToJson(dynamic obj) + { + var response = Request.CreateResponse(HttpStatusCode.OK); + response.Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/jsonP"); + return response; + } + + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/EditionController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/EditionController.cs new file mode 100644 index 0000000..d4d6e47 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/EditionController.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using AIAHTML5.ADMIN.API.Models; +using System.Web.Http.Cors; +using System.Web.Cors; +using AIAHTML5.Server.Constants; +using log4net; +using System.Text; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Controllers +{ + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + [RoutePrefix("Edition")] + public class EditionController : ApiController + { + AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); + + [Route("Editions")] + [HttpGet] + public HttpResponseMessage GetEditions() + { + List EditionList = new List(); + try + { + EditionList = EditionModel.GetEditions(dbContext); + return Request.CreateResponse(HttpStatusCode.OK, EditionList); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/LicenseController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/LicenseController.cs new file mode 100644 index 0000000..7b34f3a --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/LicenseController.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using AIAHTML5.ADMIN.API.Models; +using System.Web.Http.Cors; +using System.Web.Cors; +using AIAHTML5.Server.Constants; +using log4net; +using System.Text; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Controllers +{ + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + [RoutePrefix("License")] + public class LicenseController : ApiController + { + AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); + + [Route("LicenseTypes")] + [HttpGet] + public HttpResponseMessage GetLicenseTypes() + { + List LicenseTypeList = new List(); + try + { + LicenseTypeList = LicenseTypeModel.GetLicenseTypes(dbContext); + return Request.CreateResponse(HttpStatusCode.OK, LicenseTypeList); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("Licenses")] + [HttpGet] + public HttpResponseMessage GetLicenses(string accountNumber, string licenseeFirstName, string licenseeLastName, byte licenseTypeId, + string institutionName, int stateId, int countryId, string emailId, DateTime subscriptionStartDate, DateTime subscriptionEndDate, + bool isActive) + { + List LicenseList = new List(); + try + { + LicenseList = LicenseModel.GetLicenses(dbContext, accountNumber, licenseeFirstName, licenseeLastName, licenseTypeId, institutionName, + stateId, countryId, emailId, subscriptionStartDate, subscriptionEndDate, isActive); + return Request.CreateResponse(HttpStatusCode.OK, LicenseList); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("InsertLicense")] + [HttpPost] + public HttpResponseMessage InsertLicense(JObject jsonData) + { + bool Status = false; + LicenseModel licenseModel = new LicenseModel(); + licenseModel.LicenseId = jsonData["licenseId"].Value(); + licenseModel.AccountNumber = jsonData["accountNumber"].Value(); + licenseModel.LicenseeFirstName = jsonData["licenseeFirstName"].Value(); + licenseModel.LicenseeLastName = jsonData["licenseeLastName"].Value(); + licenseModel.LicenseTypeId = jsonData["licenseTypeId"].Value(); + licenseModel.AccountTypeId = jsonData["accountTypeId"].Value(); + licenseModel.InstitutionName = jsonData["institutionName"].Value(); + licenseModel.Address1 = jsonData["address1"].Value(); + licenseModel.Address2 = jsonData["address2"].Value(); + licenseModel.City = jsonData["city"].Value(); + licenseModel.Zip = jsonData["zip"].Value(); + licenseModel.StateId = jsonData["stateId"].Value(); + licenseModel.CountryId = jsonData["countryId"].Value(); + licenseModel.Phone = jsonData["phone"].Value(); + licenseModel.EmailId = jsonData["email"].Value(); + licenseModel.TotalLogins = jsonData["totalLogins"].Value(); + licenseModel.EditionLogins = jsonData["editionLogins"].Value(); + licenseModel.Price = jsonData["price"].Value(); + licenseModel.ProductKey = jsonData["productKey"].Value(); + licenseModel.MasterSiteUrl = jsonData["masterSiteUrl"].Value(); + licenseModel.SiteUrlFrom = jsonData["siteFromUrl"].Value(); + licenseModel.SiteUrlTo = jsonData["siteToUrl"].Value(); + licenseModel.NoOfImages = jsonData["noOfImages"].Value(); + licenseModel.LoginId = jsonData["loginId"].Value(); + licenseModel.Password = jsonData["password"].Value(); + licenseModel.SubscriptionStartDate = jsonData["subscriptionStartDate"].Value(); + licenseModel.SubscriptionEndDate = jsonData["subscriptionEndDate"].Value(); + licenseModel.SecurityQuestionId = jsonData["securityQuestionId"].Value(); + licenseModel.Answer = jsonData["answer"].Value(); + licenseModel.TestLicenseEditionId = jsonData["testLicenseEditionId"].Value(); + licenseModel.CreatorId = jsonData["creatorId"].Value(); + try + { + Status = LicenseModel.InsertLicense(dbContext, licenseModel); + if (Status) + { + return Request.CreateResponse(HttpStatusCode.OK, Status.ToString()); + } + else + { + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, Status.ToString()); + } + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("UpdateLicense")] + [HttpPost] + public HttpResponseMessage UpdateLicense(JObject jsonData) + { + bool Status = false; + LicenseModel licenseModel = new LicenseModel(); + licenseModel.LicenseId = jsonData["licenseId"].Value(); + licenseModel.AccountNumber = jsonData["accountNumber"].Value(); + licenseModel.LicenseeFirstName = jsonData["licenseeFirstName"].Value(); + licenseModel.LicenseeLastName = jsonData["licenseeLastName"].Value(); + licenseModel.LicenseTypeId = jsonData["licenseTypeId"].Value(); + licenseModel.AccountTypeId = jsonData["accountTypeId"].Value(); + licenseModel.InstitutionName = jsonData["institutionName"].Value(); + licenseModel.Address1 = jsonData["address1"].Value(); + licenseModel.Address2 = jsonData["address2"].Value(); + licenseModel.City = jsonData["city"].Value(); + licenseModel.Zip = jsonData["zip"].Value(); + licenseModel.StateId = jsonData["stateId"].Value(); + licenseModel.CountryId = jsonData["countryId"].Value(); + licenseModel.Phone = jsonData["phone"].Value(); + licenseModel.EmailId = jsonData["email"].Value(); + licenseModel.TotalLogins = jsonData["totalLogins"].Value(); + licenseModel.EditionLogins = jsonData["editionLogins"].Value(); + licenseModel.Price = jsonData["price"].Value(); + licenseModel.ProductKey = jsonData["productKey"].Value(); + licenseModel.MasterSiteUrl = jsonData["masterSiteUrl"].Value(); + licenseModel.SiteUrlFrom = jsonData["siteUrlFrom"].Value(); + licenseModel.SiteUrlTo = jsonData["siteUrlTo"].Value(); + licenseModel.NoOfImages = jsonData["noOfImages"].Value(); + licenseModel.LoginId = jsonData["loginId"].Value(); + licenseModel.Password = jsonData["password"].Value(); + licenseModel.SubscriptionStartDate = jsonData["subscriptionStartDate"].Value(); + licenseModel.SubscriptionEndDate = jsonData["subscriptionEndDate"].Value(); + licenseModel.RenewDate = jsonData["renewDate"].Value(); + licenseModel.SecurityQuestionId = jsonData["securityQuestionId"].Value(); + licenseModel.Answer = jsonData["answer"].Value(); + licenseModel.TestLicenseEditionId = jsonData["testLicenseEditionId"].Value(); + licenseModel.CreatorId = jsonData["creatorId"].Value(); + licenseModel.IsActive = jsonData["isActive"].Value(); + licenseModel.IsRenew = jsonData["renew"].Value(); + try + { + Status = LicenseModel.UpdateLicense(dbContext, licenseModel); + if (Status) + { + return Request.CreateResponse(HttpStatusCode.OK, Status.ToString()); + } + else + { + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, Status.ToString()); + } + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("GetLicense")] + [HttpGet] + public HttpResponseMessage GetLicense(int LicenseId) + { + LicenseModel LicenseEntity = new LicenseModel(); + try + { + LicenseEntity = LicenseModel.GetLicenseById(dbContext, LicenseId); + return Request.CreateResponse(HttpStatusCode.OK, LicenseEntity); + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + + [Route("DeleteLicense")] + [HttpGet] + public HttpResponseMessage DeleteLicense(int LicenseId) + { + bool Status = false; + try + { + Status = LicenseModel.DeleteLicense(dbContext, LicenseId); + if (Status) + { + return Request.CreateResponse(HttpStatusCode.OK, Status.ToString()); + } + else + { + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, Status.ToString()); + } + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs new file mode 100644 index 0000000..711a9d8 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using AIAHTML5.ADMIN.API.Models; +using System.Web.Http.Cors; +using System.Web.Cors; +using AIAHTML5.Server.Constants; +using log4net; +using System.Text; +using AIAHTML5.ADMIN.API.Entity; +namespace AIAHTML5.ADMIN.API.Controllers +{ + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + [RoutePrefix("Report")] + public class ReportController : ApiController + { + AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); + public IHttpActionResult GetUsageReport(string sFromDate, string sToDate, string sAccoutNumber, string sZip, int iState, int iCountry) + { + var lstUsageReport = dbContext.GetUsageReport(sFromDate, sToDate, sAccoutNumber, sZip, iState, iCountry).ToList(); + return Ok(lstUsageReport); + } + + [Route("Api/GetCustomerSummeryReport")] + [HttpGet] + public IHttpActionResult GetCustomerSummeryReport(string sAccoutNumber, string sLicenseeFullName, Nullable iStartPrice, Nullable iEndPrice, int iLicenseType, int iAccountType, string sZip, int iState, int iCountry) + { + var lstCustomerSummeryReport = dbContext.GetCustomerSummary(sAccoutNumber, sLicenseeFullName, iStartPrice, iEndPrice, (byte)iLicenseType, (byte)iAccountType, sZip, iState, iCountry).ToList(); + return Ok(lstCustomerSummeryReport); + } + + + [Route("Api/GetExpiringSubscriptionReport")] + [HttpGet] + public IHttpActionResult GetExpiringSubscriptionReport(string sFromDate, string sToDate, Nullable iStartPrice, Nullable iEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId) + { + var lstExpiringSubscriptionReport = dbContext.GetExpiringLicenses(sFromDate, sToDate, iStartPrice, iEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId).ToList(); + return Ok(lstExpiringSubscriptionReport); + } + + [Route("Api/GetSubscriptionReport")] + [HttpGet] + public IHttpActionResult GetSubscriptionReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId) + { + + var lstExpiringSubscriptionReport = dbContext.GetSubscribedLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId).ToList(); + return Ok(lstExpiringSubscriptionReport); + } + [Route("Api/GetSubscriptionCancellationReport")] + [HttpGet] + public IHttpActionResult GetSubscriptionCancellationReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId) + { + + var lstExpiringSubscriptionReport = dbContext.GetCancelledLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId).ToList(); + return Ok(lstExpiringSubscriptionReport); + } + + [Route("Api/GetNetAdSummaryReport")] + [HttpGet] + public IHttpActionResult GetNetAdSummaryReport(string sFromDate, string sToDate, decimal iStartPrice, decimal iEndPrice, int iLicenseTypeId) + { + try + { + var lstNetAdSummaryReport = dbContext.GetNetAdSummaryReport(sFromDate, sToDate, iStartPrice, iEndPrice, (byte)iLicenseTypeId).ToList(); + return Ok(lstNetAdSummaryReport); + } + catch (Exception ex) + { + return Ok(ex.Message.ToString()); + } + } + + [Route("Api/GetSiteLicenseUsageReport")] + [HttpGet] + public IHttpActionResult GetSiteLicenseUsageReport(string sFromDate, string sToDate, string sAccountNumber, int iEdition) + { + try + { + var lstSiteLicenseUsageReport = dbContext.GetSiteLicenseUsageReport(sFromDate, sToDate, sAccountNumber, (byte)iEdition).ToList(); + return Ok(lstSiteLicenseUsageReport); + } + catch (Exception ex) + { + return Ok(ex.Message.ToString()); + } + } + + [Route("Api/GetDiscountReport")] + [HttpGet] + public IHttpActionResult GetDiscountReport(string sFromDate, string sToDate, int iDiscountCode, string sAccountNumber) + { + try + { + var lstDiscountReport = dbContext.GetDiscountReport(sFromDate, sToDate, iDiscountCode, sAccountNumber).ToList(); + return Ok(lstDiscountReport); + } + catch (Exception ex) + { + return Ok(ex.Message.ToString()); + } + } + + [Route("Api/GetImageExportReport")] + [HttpGet] + public IHttpActionResult GetImageExportReport(string sFromDate, string sToDate, string sAccountNumber) + { + try + { + if (sAccountNumber == null) + sAccountNumber = string.Empty; + var lstImageExportReport = dbContext.GetExportedImageDetails(sFromDate, sToDate, sAccountNumber).ToList(); + return Ok(lstImageExportReport); + } + catch (Exception ex) + { + return Ok(ex.Message.ToString()); + } + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index ae24dcf..51ce9bf 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -190,6 +190,26 @@ namespace AIAHTML5.ADMIN.API.Controllers return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "We have encountered a technical error and same has been notified to our technical team."); } } + + [Route("ManageRight")] + [HttpGet] + public IHttpActionResult UserManageRight(int UserId,string UserType) + { + dbContext.Configuration.ProxyCreationEnabled = false; + try + { + List UserRights = dbContext.usp_GetManageRights(UserId, UserType).ToList(); + return Ok(UserRights); + } + catch(Exception ex) + { + var message = new HttpResponseMessage(HttpStatusCode.BadRequest) + { + Content = new StringContent("We have encountered a technical error and same has been notified to our technical team.") + }; + throw new HttpResponseException(message); + } + } #endregion #region Add User diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs index eea7734..babca1b 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs @@ -3140,5 +3140,86 @@ namespace AIAHTML5.ADMIN.API.Entity return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_UpdateAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, sEmailIdParameter, idParameter, iCreatorIdParameter, isActiveParameter, status); } + + public virtual ObjectResult usp_GetEditions() + { + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetEditions"); + } + + public virtual ObjectResult usp_GetLicenseById(Nullable id) + { + var idParameter = id.HasValue ? + new ObjectParameter("Id", id) : + new ObjectParameter("Id", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetLicenseById", idParameter); + } + + public virtual ObjectResult usp_GetLicenses(string sStartDate, string sEndDate, string sAccoutNumber, string sLicenseeFirstName, string sLicenseeLastName, Nullable iLicenseTypeId, string sInstituteName, string sEmail, Nullable iStateId, Nullable iCountryId, Nullable bisActive) + { + var sStartDateParameter = sStartDate != null ? + new ObjectParameter("sStartDate", sStartDate) : + new ObjectParameter("sStartDate", typeof(string)); + + var sEndDateParameter = sEndDate != null ? + new ObjectParameter("sEndDate", sEndDate) : + new ObjectParameter("sEndDate", typeof(string)); + + var sAccoutNumberParameter = sAccoutNumber != null ? + new ObjectParameter("sAccoutNumber", sAccoutNumber) : + new ObjectParameter("sAccoutNumber", typeof(string)); + + var sLicenseeFirstNameParameter = sLicenseeFirstName != null ? + new ObjectParameter("sLicenseeFirstName", sLicenseeFirstName) : + new ObjectParameter("sLicenseeFirstName", typeof(string)); + + var sLicenseeLastNameParameter = sLicenseeLastName != null ? + new ObjectParameter("sLicenseeLastName", sLicenseeLastName) : + new ObjectParameter("sLicenseeLastName", typeof(string)); + + var iLicenseTypeIdParameter = iLicenseTypeId.HasValue ? + new ObjectParameter("iLicenseTypeId", iLicenseTypeId) : + new ObjectParameter("iLicenseTypeId", typeof(byte)); + + var sInstituteNameParameter = sInstituteName != null ? + new ObjectParameter("sInstituteName", sInstituteName) : + new ObjectParameter("sInstituteName", typeof(string)); + + var sEmailParameter = sEmail != null ? + new ObjectParameter("sEmail", sEmail) : + new ObjectParameter("sEmail", typeof(string)); + + var iStateIdParameter = iStateId.HasValue ? + new ObjectParameter("iStateId", iStateId) : + new ObjectParameter("iStateId", typeof(int)); + + var iCountryIdParameter = iCountryId.HasValue ? + new ObjectParameter("iCountryId", iCountryId) : + new ObjectParameter("iCountryId", typeof(int)); + + var bisActiveParameter = bisActive.HasValue ? + new ObjectParameter("bisActive", bisActive) : + new ObjectParameter("bisActive", typeof(bool)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetLicenses", sStartDateParameter, sEndDateParameter, sAccoutNumberParameter, sLicenseeFirstNameParameter, sLicenseeLastNameParameter, iLicenseTypeIdParameter, sInstituteNameParameter, sEmailParameter, iStateIdParameter, iCountryIdParameter, bisActiveParameter); + } + + public virtual ObjectResult usp_GetLicenseTypes() + { + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetLicenseTypes"); + } + + public virtual ObjectResult usp_GetManageRights(Nullable userId, string roleName) + { + var userIdParameter = userId.HasValue ? + new ObjectParameter("UserId", userId) : + new ObjectParameter("UserId", typeof(int)); + + var roleNameParameter = roleName != null ? + new ObjectParameter("RoleName", roleName) : + new ObjectParameter("RoleName", typeof(string)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetManageRights", userIdParameter, roleNameParameter); + } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx index 378a5b6..0a8356b 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx @@ -2624,6 +2624,28 @@ warning 6002: The table/view 'AIADatabaseV5.dbo.VocabTermNumberToSystemMap' does + + + + + + + + + + + + + + + + + + + + + + @@ -6199,6 +6221,28 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + + + + + @@ -7044,6 +7088,81 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9410,6 +9529,101 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetEditions_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetEditions_Result.cs new file mode 100644 index 0000000..83d54a2 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetEditions_Result.cs @@ -0,0 +1,21 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetEditions_Result + { + public byte Id { get; set; } + public string Title { get; set; } + public byte Priority { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenseById_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenseById_Result.cs new file mode 100644 index 0000000..2cd5416 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenseById_Result.cs @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetLicenseById_Result + { + public int Id { get; set; } + public byte LicenseTypeId { get; set; } + public string AccountNumber { get; set; } + public byte AccountTypeId { get; set; } + public string Address1 { get; set; } + public string Address2 { get; set; } + public string LicenseeFirstName { get; set; } + public string LicenseeLastName { get; set; } + public string City { get; set; } + public int CountryId { get; set; } + public int StateId { get; set; } + public string EmailId { get; set; } + public string InstitutionName { get; set; } + public string Phone { get; set; } + public string ProductId { get; set; } + public string Zip { get; set; } + public int TotalLogins { get; set; } + public string EditionLogins { get; set; } + public Nullable SubscriptionStartDate { get; set; } + public Nullable SubscriptionEndDate { get; set; } + public Nullable NoOfImages { get; set; } + public Nullable Price { get; set; } + public string SiteUrl { get; set; } + public string SitToUrl { get; set; } + public string SiteMasterUrl { get; set; } + public Nullable UserId { get; set; } + public string Login { get; set; } + public string Password { get; set; } + public Nullable SecurityQuestionId { get; set; } + public string Answer { get; set; } + public int TotalRenewals { get; set; } + public Nullable RenewalDate { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenseTypes_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenseTypes_Result.cs new file mode 100644 index 0000000..1b2c97a --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenseTypes_Result.cs @@ -0,0 +1,20 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetLicenseTypes_Result + { + public byte Id { get; set; } + public string Title { get; set; } + public bool IsActive { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenses_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenses_Result.cs new file mode 100644 index 0000000..34defa5 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetLicenses_Result.cs @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetLicenses_Result + { + public int LicenseId { get; set; } + public string AccountNumber { get; set; } + public string LicenseType { get; set; } + public string AccountType { get; set; } + public string InstitutionName { get; set; } + public string LicenseState { get; set; } + public string LicenseCountry { get; set; } + public string EmailId { get; set; } + public Nullable CardNumber { get; set; } + public string ProductKey { get; set; } + public string ClientAdmin { get; set; } + public string LicenseeName { get; set; } + public string ContactAddress { get; set; } + public string EntryDate { get; set; } + public string LicenseStatus { get; set; } + public string ModifyDate { get; set; } + public string StartDate { get; set; } + public string RenewDate { get; set; } + public string EndDate { get; set; } + public Nullable NoofImages { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetManageRights_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetManageRights_Result.cs new file mode 100644 index 0000000..131a446 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetManageRights_Result.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetManageRights_Result + { + public int Id { get; set; } + public string Title { get; set; } + public int ParentId { get; set; } + public Nullable Priority { get; set; } + public string MenuStatus { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/AccountModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/AccountModel.cs new file mode 100644 index 0000000..c42ee51 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/AccountModel.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Models +{ + + public class AccountTypeEntityModel + { + public int Id { get; set; } + public string Title { get; set; } + public bool IsActive { get; set; } + + public static List GetActiveAccountTypes(AIADatabaseV5Entities dbContext) + { + List AccountTypeList = new List(); + AccountTypeEntityModel AccountTypeModelObj = new AccountTypeEntityModel(); + try + { + var result = dbContext.EC_GetAccountTypeList().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + AccountTypeModelObj = new AccountTypeEntityModel(); + AccountTypeModelObj.Id = item.Id; + AccountTypeModelObj.Title = item.Title; + AccountTypeList.Add(AccountTypeModelObj); + } + } + } + catch (Exception ex) { } + return AccountTypeList; + } + + } + +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/CommonModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/CommonModel.cs new file mode 100644 index 0000000..184b29e --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/CommonModel.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Models +{ + public class CountryModel + { + public int Id { get; set; } + public string CountryName { get; set; } + public string CountryCode { get; set; } + + public static List GetCountries(AIADatabaseV5Entities dbContext) + { + List CountryList = new List(); + CountryModel CountryModelObj = new CountryModel(); + try + { + var result = dbContext.EC_GetCountryList().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + CountryModelObj = new CountryModel(); + CountryModelObj.Id = item.Id; + CountryModelObj.CountryName = item.CountryName; + CountryList.Add(CountryModelObj); + } + } + } + catch (Exception ex) { } + return CountryList; + } + } + + public class StateModel + { + public int Id { get; set; } + public string StateName { get; set; } + public string StateCode { get; set; } + + public static List GetUsStates(AIADatabaseV5Entities dbContext) + { + List StateList = new List(); + StateModel StateModelObj = new StateModel(); + try + { + var result = dbContext.EC_GetStateList().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + StateModelObj = new StateModel(); + StateModelObj.Id = item.Id; + StateModelObj.StateName = item.StateName; + StateList.Add(StateModelObj); + } + } + } + catch (Exception ex) { } + return StateList; + } + } + + public class SecurityQuestionModel + { + public int Id { get; set; } + public string Title { get; set; } + + public static List GetSecurityQuestions(AIADatabaseV5Entities dbContext) + { + List SecurityQuestionList = new List(); + SecurityQuestionModel SecurityQuestionObj = new SecurityQuestionModel(); + try + { + var result = dbContext.EC_GetSecurityQuestionList().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + SecurityQuestionObj = new SecurityQuestionModel(); + SecurityQuestionObj.Id = item.Id; + SecurityQuestionObj.Title = item.Title; + SecurityQuestionList.Add(SecurityQuestionObj); + } + } + } + catch (Exception ex) { } + return SecurityQuestionList; + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/EditionModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/EditionModel.cs new file mode 100644 index 0000000..a96714e --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/EditionModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Models +{ + public class EditionModel + { + public int Id { get; set; } + public string Title { get; set; } + public int Priority { get; set; } + public bool IsActive { get; set; } + + public static List GetEditions(AIADatabaseV5Entities dbContext) + { + List EditionList = new List(); + EditionModel EditionObj = new EditionModel(); + int i = 0; + try + { + var result = dbContext.usp_GetEditions().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + EditionObj = new EditionModel(); + EditionObj.Id = item.Id; + EditionObj.Title = item.Title; + EditionObj.Priority = item.Priority; + EditionObj.IsActive = item.IsActive; + EditionList.Add(EditionObj); + } + } + } + catch (Exception ex) { } + return EditionList; + } + } + +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs new file mode 100644 index 0000000..ffa9c76 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/LicenseModel.cs @@ -0,0 +1,304 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using AIAHTML5.ADMIN.API.Entity; + +namespace AIAHTML5.ADMIN.API.Models +{ + public class LicenseModel + { + public int LicenseId { get; set; } + public string AccountNumber { get; set; } + public byte AccountTypeId { get; set; } + public string AccountTypeName { get; set; } + public string LicenseeFirstName { get; set; } + public string LicenseeLastName { get; set; } + public string LicenseeName { get; set; } + public byte LicenseTypeId { get; set; } + public string LicenseTypeName { get; set; } + public string InstitutionName { get; set; } + public int? StateId { get; set; } + public int? CountryId { get; set; } + public string LicenseState { get; set; } + public string Address { get; set; } + public string Address1 { get; set; } + public string Address2 { get; set; } + public string City { get; set; } + public string Zip { get; set; } + public string Phone { get; set; } + public string LicenseCountry { get; set; } + public string EmailId { get; set; } + public int? NoOfImages { get; set; } + public string ClientAdmin { get; set; } + public string ProductKey { get; set; } + public int? CardNumber { get; set; } + public DateTime SubscriptionStartDate { get; set; } + public DateTime SubscriptionEndDate { get; set; } + public DateTime EntryDate { get; set; } + public DateTime RenewDate { get; set; } + public DateTime ModifyDate { get; set; } + public bool IsActive { get; set; } + public int? TotalLogins { get; set; } + public string EditionLogins { get; set; } + public decimal Price { get; set; } + public string LoginId { get; set; } + public string Password { get; set; } + public byte? SecurityQuestionId { get; set; } + public string Answer { get; set; } + public int CreatorId { get; set; } + public int TotalRenewals { get; set; } + public string MasterSiteUrl { get; set; } + public string SiteUrlTo { get; set; } + public string SiteUrlFrom { get; set; } + public byte? TestLicenseEditionId { get; set; } + public bool IsRenew { get; set; } + + public static List GetLicenses(AIADatabaseV5Entities dbContext, string accountNumber, string licenseeFirstName, + string licenseeLastName, byte licenseTypeId, string institutionName, int stateId, int countryId, string emailId, + DateTime subscriptionStartDate, DateTime subscriptionEndDate, bool isActive) + { + List LicenseList = new List(); + LicenseModel LicenseObj = new LicenseModel(); + int i = 0; + try + { + var result = dbContext.usp_GetLicenses( + (subscriptionStartDate > DateTime.MinValue ? subscriptionStartDate.ToShortDateString() : "01/01/01"), + (subscriptionEndDate > DateTime.MinValue ? subscriptionEndDate.ToShortDateString() : "01/01/01"), + (accountNumber == null ? "" : accountNumber), (licenseeFirstName == null ? "" : licenseeFirstName), + (licenseeLastName == null ? "" : licenseeLastName), licenseTypeId, (institutionName == null ? "" : institutionName), + (emailId == null ? "" : emailId), stateId, countryId, isActive).ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + LicenseObj = new LicenseModel(); + LicenseObj.LicenseId = item.LicenseId; + LicenseObj.AccountNumber = item.AccountNumber; + LicenseObj.AccountTypeName = item.AccountType; + LicenseObj.LicenseeName = item.LicenseeName; + LicenseObj.LicenseState = item.LicenseState; + LicenseObj.LicenseCountry = item.LicenseCountry; + LicenseObj.Address = item.ContactAddress; + LicenseObj.InstitutionName = item.InstitutionName; + LicenseObj.LicenseTypeName = item.LicenseType; + LicenseObj.EmailId = item.EmailId; + LicenseObj.NoOfImages = item.NoofImages; + LicenseObj.ClientAdmin = item.ClientAdmin; + LicenseObj.CardNumber = item.CardNumber; + LicenseObj.ProductKey = item.ProductKey; + LicenseObj.SubscriptionStartDate = DateTime.ParseExact(item.StartDate, "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); + LicenseObj.SubscriptionEndDate = DateTime.ParseExact(item.EndDate, "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); + LicenseObj.EntryDate = DateTime.ParseExact(item.EntryDate, "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); + LicenseObj.RenewDate = DateTime.ParseExact((item.RenewDate == "" ? "01/01/0001" : item.RenewDate), "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); + LicenseObj.ModifyDate = DateTime.ParseExact((item.ModifyDate == "" ? "01/01/0001" : item.ModifyDate), "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); + LicenseObj.IsActive = (item.LicenseStatus == "Active" ? true : false); + LicenseList.Add(LicenseObj); + i++; + if (i >= 100) break; + } + } + } + catch (Exception ex) { } + return LicenseList; + } + + public static LicenseModel GetLicenseById(AIADatabaseV5Entities dbContext, int LicenseId) + { + LicenseModel LicenseObj = new LicenseModel(); + try + { + var result = dbContext.usp_GetLicenseById(LicenseId).ToList(); + if (result.Count > 0) + { + LicenseObj.LicenseId = result[0].Id; + LicenseObj.LicenseTypeId = result[0].LicenseTypeId; + LicenseObj.AccountNumber = result[0].AccountNumber; + LicenseObj.AccountTypeId = result[0].AccountTypeId; + LicenseObj.LicenseeFirstName = result[0].LicenseeFirstName; + LicenseObj.LicenseeLastName = result[0].LicenseeLastName; + LicenseObj.EditionLogins = result[0].EditionLogins; + LicenseObj.TotalLogins = result[0].TotalLogins; + LicenseObj.Address1 = result[0].Address1; + LicenseObj.Address2 = result[0].Address2; + LicenseObj.City = result[0].City; + LicenseObj.CountryId = result[0].CountryId; + LicenseObj.StateId = result[0].StateId; + LicenseObj.InstitutionName = result[0].InstitutionName; + LicenseObj.EmailId = result[0].EmailId; + LicenseObj.Zip = result[0].Zip; + LicenseObj.Phone = result[0].Phone; + LicenseObj.TotalLogins = result[0].TotalLogins; + LicenseObj.ProductKey = result[0].ProductId; + LicenseObj.Price = result[0].Price.Value; + LicenseObj.NoOfImages = result[0].NoOfImages; + LicenseObj.MasterSiteUrl = result[0].SiteUrl; + LicenseObj.SiteUrlTo = result[0].SitToUrl; + LicenseObj.SiteUrlFrom = result[0].SiteMasterUrl; + LicenseObj.LoginId = result[0].Login; + LicenseObj.Password = result[0].Password; + LicenseObj.SecurityQuestionId = (byte?)result[0].SecurityQuestionId; + LicenseObj.Answer = result[0].Answer; + LicenseObj.IsActive = result[0].IsActive; + LicenseObj.TotalRenewals = result[0].TotalRenewals; + LicenseObj.SubscriptionStartDate = (result[0].SubscriptionStartDate == null ? DateTime.MinValue : result[0].SubscriptionStartDate.Value); + LicenseObj.SubscriptionEndDate = (result[0].SubscriptionEndDate == null ? DateTime.MinValue : result[0].SubscriptionEndDate.Value); + LicenseObj.RenewDate = (result[0].RenewalDate == null ? DateTime.MinValue : result[0].RenewalDate.Value); + } + } + catch (Exception ex) { } + return LicenseObj; + } + + public static bool InsertLicense(AIADatabaseV5Entities dbContext, LicenseModel licenseModel) + { + bool status = false; + try + { + switch (licenseModel.LicenseTypeId) + { + case 1: + var result = dbContext.InsertNewLicenseAccount(licenseModel.AccountNumber, licenseModel.LicenseeFirstName, licenseModel.LicenseeLastName, + licenseModel.LicenseTypeId, licenseModel.AccountTypeId, licenseModel.InstitutionName, licenseModel.Address1, licenseModel.Address2, + licenseModel.City, licenseModel.Zip, licenseModel.StateId, licenseModel.CountryId, licenseModel.Phone, licenseModel.EmailId, + licenseModel.TotalLogins, licenseModel.SubscriptionStartDate.ToString("MM/dd/yyyy"), licenseModel.SubscriptionEndDate.ToString("MM/dd/yyyy"), + licenseModel.MasterSiteUrl, licenseModel.EditionLogins, licenseModel.Price, licenseModel.ProductKey, licenseModel.SiteUrlTo, + licenseModel.SiteUrlFrom, licenseModel.NoOfImages); + if (result.Count() > 0) + { + status = true; + } + break; + case 2: + result = dbContext.InsertSingleLicenseAccount(licenseModel.AccountNumber, licenseModel.LicenseeFirstName, licenseModel.LicenseeLastName, licenseModel.AccountTypeId, + licenseModel.InstitutionName, licenseModel.Address1, licenseModel.Address2, licenseModel.City, licenseModel.Zip, + licenseModel.StateId, licenseModel.CountryId, licenseModel.Phone, licenseModel.EmailId, licenseModel.TotalLogins, + licenseModel.SubscriptionStartDate.ToString("MM/dd/yyyy"), licenseModel.SubscriptionEndDate.ToString("MM/dd/yyyy"), + licenseModel.EditionLogins, licenseModel.Price, licenseModel.ProductKey, licenseModel.LoginId, licenseModel.Password, + licenseModel.SecurityQuestionId, licenseModel.Answer, licenseModel.CreatorId, licenseModel.NoOfImages); + if (result.Count() > 0) + { + status = true; + } + break; + case 3: + result = dbContext.InsertNewLicenseAccount(licenseModel.AccountNumber, licenseModel.LicenseeFirstName, licenseModel.LicenseeLastName, + licenseModel.LicenseTypeId, licenseModel.AccountTypeId, licenseModel.InstitutionName, licenseModel.Address1, licenseModel.Address2, + licenseModel.City, licenseModel.Zip, licenseModel.StateId, licenseModel.CountryId, licenseModel.Phone, licenseModel.EmailId, + licenseModel.TotalLogins, licenseModel.SubscriptionStartDate.ToString("MM/dd/yyyy"), licenseModel.SubscriptionEndDate.ToString("MM/dd/yyyy"), + licenseModel.MasterSiteUrl, licenseModel.EditionLogins, licenseModel.Price, licenseModel.ProductKey, licenseModel.SiteUrlTo, + licenseModel.SiteUrlFrom, licenseModel.NoOfImages); + if (result.Count() > 0) + { + status = true; + } + break; + case 4: + var result1 = dbContext.InsertResellerLicenseAccount(licenseModel.LicenseeFirstName, licenseModel.LicenseeLastName, licenseModel.LicenseTypeId, + licenseModel.AccountTypeId, licenseModel.InstitutionName, licenseModel.Address1, licenseModel.Address2, + licenseModel.City, licenseModel.Zip, licenseModel.StateId, licenseModel.CountryId, licenseModel.Phone, licenseModel.EmailId, + licenseModel.TotalLogins, licenseModel.SubscriptionStartDate.ToString("MM/dd/yyyy"), licenseModel.SubscriptionEndDate.ToString("MM/dd/yyyy"), + licenseModel.EditionLogins, licenseModel.Price, licenseModel.CreatorId, licenseModel.ProductKey, licenseModel.NoOfImages); + if (result1.Count() > 0) + { + status = true; + } + break; + case 5: + result = dbContext.InsertTestLicenseAccount(licenseModel.AccountNumber, licenseModel.LicenseeFirstName, licenseModel.LicenseeLastName, + licenseModel.LoginId, licenseModel.Password, licenseModel.EmailId, licenseModel.AccountTypeId, licenseModel.TestLicenseEditionId, + licenseModel.Address1, licenseModel.City, licenseModel.Zip, licenseModel.StateId, licenseModel.CountryId, licenseModel.Phone, + licenseModel.SubscriptionStartDate.ToString("MM/dd/yyyy"), licenseModel.SubscriptionEndDate.ToString("MM/dd/yyyy"), + licenseModel.CreatorId, licenseModel.NoOfImages); + if (result.Count() > 0) + { + status = true; + } + break; + } + return status; + } + catch (Exception ex) + { + return false; + } + } + + public static bool UpdateLicense(AIADatabaseV5Entities dbContext, LicenseModel licenseModel) + { + bool status = false; + try + { + var result = dbContext.UpdateLicenseAccount(licenseModel.LicenseId, licenseModel.LicenseeFirstName, licenseModel.LicenseeLastName, + licenseModel.LicenseTypeId, licenseModel.AccountTypeId, licenseModel.InstitutionName, licenseModel.Address1, licenseModel.Address2, + licenseModel.City, licenseModel.Zip, licenseModel.StateId, licenseModel.CountryId, licenseModel.Phone, licenseModel.EmailId, + (byte)(licenseModel.IsActive == false ? 0 : 1), licenseModel.TotalLogins, (byte)(licenseModel.IsRenew == false ? 0 : 1), + licenseModel.SubscriptionStartDate.ToString("MM/dd/yyyy"), licenseModel.SubscriptionEndDate.ToString("MM/dd/yyyy"), + licenseModel.RenewDate.ToString("MM/dd/yyyy"), licenseModel.MasterSiteUrl, licenseModel.EditionLogins, licenseModel.Price, + licenseModel.ProductKey, licenseModel.SiteUrlTo, licenseModel.SiteUrlFrom, licenseModel.NoOfImages); + if (result.Count() > 0) + { + status = true; + } + return status; + } + catch (Exception ex) + { + return false; + } + } + + public static bool DeleteLicense(AIADatabaseV5Entities dbContext, int LicenseId) + { + try + { + var spStatus = dbContext.DeleteLicense(LicenseId); + if (spStatus.Count() > 0) + { + return true; + } + else + { + return false; + } + } + catch (Exception ex) + { + return false; + } + } + } + + public class LicenseTypeModel + { + public int Id { get; set; } + public string Title { get; set; } + public bool IsActive { get; set; } + + public static List GetLicenseTypes(AIADatabaseV5Entities dbContext) + { + List LicenseTypeList = new List(); + LicenseTypeModel LicenseTypeModelObj = new LicenseTypeModel(); + try + { + var result = dbContext.usp_GetLicenseTypes().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + LicenseTypeModelObj = new LicenseTypeModel(); + LicenseTypeModelObj.Id = item.Id; + LicenseTypeModelObj.Title = item.Title; + LicenseTypeModelObj.IsActive = item.IsActive; + LicenseTypeList.Add(LicenseTypeModelObj); + } + } + } + catch (Exception ex) { } + return LicenseTypeList; + } + + } + +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/SharedModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/SharedModel.cs index ec8fb92..c4a3292 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/SharedModel.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/SharedModel.cs @@ -7,6 +7,10 @@ namespace AIAHTML5.ADMIN.API.Models { public class AccountTypeModel { + public int Id { get; set; } + public string Title { get; set; } + public bool isActive { get; set; } + public static List GetAccountTypeList(AIADatabaseV5Entities dbContext, int Id) { var accountTypeEntity = dbContext.usp_GetAccountTypeList(Id).ToList(); @@ -14,5 +18,27 @@ namespace AIAHTML5.ADMIN.API.Models //AccountTypelist.Insert(0, new AccountType { Id = 0, Title = "All" }); return AccountTypelist; } + + public static List GetAccountTypes(AIADatabaseV5Entities dbContext) + { + List AccountTypeList = new List(); + AccountTypeModel AccountTypeModelObj = new AccountTypeModel(); + try + { + var result = dbContext.EC_GetAccountTypeList().ToList(); + if (result.Count > 0) + { + foreach (var item in result) + { + AccountTypeModelObj = new AccountTypeModel(); + AccountTypeModelObj.Id = item.Id; + AccountTypeModelObj.Title = item.Title; + AccountTypeList.Add(AccountTypeModelObj); + } + } + } + catch (Exception ex) { } + return AccountTypeList; + } } } \ No newline at end of file