using System; using System.Collections.Generic; using System.Linq; using System.Web; using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Models { public class SiteModel { public int Id { get; set; } public int LicenseId { get; set; } public string Ip { get; set; } public string Title { get; set; } public string SiteIpTo { get; set; } public string MasterIpTo { get; set; } public DateTime CreationDate { get; set; } public DateTime ModifiedDate { get; set; } public string InstituteName { get; set; } public string City { get; set; } public string Zip { get; set; } public string Phone { get; set; } public string Address1 { get; set; } public string Address2 { get; set; } public int? StateId { get; set; } public int? CountryId { get; set; } public string Department { get; set; } public int SiteUserId { get; set; } public string SiteUserFirstName { get; set; } public string SiteUserEmailId { get; set; } public bool? IsActive { get; set; } public bool IsMaster { get; set; } public bool? IsModesty { get; set; } public string SiteEditionIds { get; set; } public static SiteModel GetSiteById(AIADatabaseV5Entities dbContext, int SiteId) { LicenseModel LicenseObj = new LicenseModel(); SiteModel SiteModelObj = new SiteModel(); try { var result = dbContext.usp_GetSiteById(SiteId).ToList(); SiteModelObj.Id = result[0].Id; SiteModelObj.Ip = result[0].SiteIp; SiteModelObj.SiteIpTo = result[0].SiteIPTo; SiteModelObj.MasterIpTo = result[0].SiteMasterIPTo; SiteModelObj.InstituteName = result[0].InstituteName; SiteModelObj.Department = result[0].Department; SiteModelObj.City = result[0].City; SiteModelObj.Phone = result[0].Phone; SiteModelObj.Zip = result[0].Zip; SiteModelObj.Address1 = result[0].Address1; SiteModelObj.Address2 = result[0].Address2; SiteModelObj.CountryId = result[0].CountryId; SiteModelObj.StateId = result[0].StateId; SiteModelObj.SiteUserId = result[0].UserId; SiteModelObj.SiteUserEmailId = result[0].EmailId; SiteModelObj.IsMaster = result[0].IsMaster; SiteModelObj.IsActive = result[0].IsActive; SiteModelObj.SiteUserFirstName = result[0].FirstName; SiteModelObj.Title = result[0].Title; SiteModelObj.CreationDate = DateTime.ParseExact(result[0].CreationDate, "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); SiteModelObj.ModifiedDate = DateTime.ParseExact(result[0].ModifiedDate, "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture); } catch (Exception ex) { } return SiteModelObj; } public static List> GetSiteAccountEditions(AIADatabaseV5Entities dbContext, int SiteId, int LicenseId) { List> SiteAccountEditionList = new List>(); Tuple SiteEditionObj; try { var result = dbContext.usp_GetSiteAccountEditions(SiteId, LicenseId).ToList(); if (result.Count > 0) { foreach (var item in result) { SiteEditionObj = new Tuple(item.LicenseEditionId, item.Id, item.Title); SiteAccountEditionList.Add(SiteEditionObj); } } } catch (Exception ex) { } return SiteAccountEditionList; } public static int InsertUpdateSiteAccount(AIADatabaseV5Entities dbContext, SiteModel SiteEntity) { var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); try { dbContext.usp_InsertUpdateSiteAccount(SiteEntity.Id, SiteEntity.Ip, SiteEntity.Title, SiteEntity.InstituteName, SiteEntity.Department, SiteEntity.Address1, SiteEntity.Address2, SiteEntity.City, SiteEntity.Zip, SiteEntity.Phone, SiteEntity.StateId, SiteEntity.CountryId, SiteEntity.IsMaster, SiteEntity.CreationDate, SiteEntity.ModifiedDate, SiteEntity.IsActive, SiteEntity.SiteUserId, SiteEntity.SiteIpTo, SiteEntity.LicenseId, SiteEntity.SiteEditionIds, spStatus); return (int)spStatus.Value; } catch (Exception ex) { return 0; } } public static bool DeleteSiteAccount(AIADatabaseV5Entities dbContext, int SiteId, int LicenseId, int UserId) { var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); try { dbContext.usp_DeleteSiteAccount(SiteId, LicenseId, UserId, spStatus); return (bool)spStatus.Value; } catch (Exception ex) { return false; } } } }