using System; using System.Collections.Generic; using System.Linq; using System.Web; using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Models { public class UserGroupModel { public int Id { get; set; } public int LicenseId { get; set; } public string Title { get; set; } public DateTime? CreationDate { get; set; } public DateTime? ModifiedDate { get; set; } public bool? IsActive { get; set; } public int? TotalUsers { get; set; } public static List GetLicenseUserGroups(AIADatabaseV5Entities dbContext, int LicenseId, int pageNo, int pageLength, out int recordCount) { List UserGroupList = new List(); UserGroupModel UserGroupObj = new UserGroupModel(); var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); recordCount = 0; try { var result = dbContext.usp_GetLicenseUserGroups(LicenseId, pageNo, pageLength, spRecordCount).ToList(); foreach (var item in result) { UserGroupObj = new UserGroupModel(); UserGroupObj.Id = item.Id; UserGroupObj.LicenseId = item.LicenseId; UserGroupObj.Title = item.Title; UserGroupObj.IsActive = item.IsActive; UserGroupObj.ModifiedDate = item.ModifiedDate; UserGroupObj.CreationDate = item.CreationDate; UserGroupObj.TotalUsers = item.TotalUsers; UserGroupList.Add(UserGroupObj); } recordCount = (int)spRecordCount.Value; } catch (Exception ex) { } return UserGroupList; } public static List GetLicenseUserGroupUsers(AIADatabaseV5Entities dbContext, int LicenseId, int UserGroupId, bool AllUsers, int pageNo, int pageLength, out int recordCount) { List UserList = new List(); UserModel UserModelObj = new UserModel(); var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); recordCount = 0; try { var result = dbContext.usp_GetLicenseUserGroupUsers(LicenseId, UserGroupId, AllUsers, pageNo, pageLength, spRecordCount).ToList(); foreach (var item in result) { UserModelObj = new UserModel(); UserModelObj.Id = item.Id; UserModelObj.FirstName = item.FirstName; UserModelObj.LastName = item.LastName; UserModelObj.LoginId = item.LoginId; UserModelObj.EmailId = item.EmailId; UserModelObj.ProductEdition = item.Title; UserModelObj.InGroup = item.InGroup; UserList.Add(UserModelObj); } recordCount = (int)spRecordCount.Value; } catch (Exception ex) { } return UserList; } public static bool InsertUpdateLicenseUserGroup(AIADatabaseV5Entities dbContext, UserGroupModel UserGroupEntity) { var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); try { dbContext.usp_InsertUpdateLicenseUserGroup(UserGroupEntity.Id, UserGroupEntity.LicenseId, UserGroupEntity.Title, UserGroupEntity.CreationDate, UserGroupEntity.ModifiedDate, UserGroupEntity.IsActive, spStatus); return (bool)spStatus.Value; } catch (Exception ex) { return false; } } public static bool UpdateLicenseUserGroupUsers(AIADatabaseV5Entities dbContext, int UserGroupId, string UserIds) { var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); try { dbContext.usp_UpdateLicenseUserGroupUsers(UserGroupId, UserIds, spStatus); return (bool)spStatus.Value; } catch (Exception ex) { return false; } } public static bool DeleteLicenseUserGroup(AIADatabaseV5Entities dbContext, int UserGroupId) { var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); try { dbContext.usp_DeleteLicenseUserGroup(UserGroupId, spStatus); return (bool)spStatus.Value; } catch (Exception ex) { return false; } } } }