public List <InConfigurationDetails> GetConfiguration() { try { List <InConfigurationDetails> inConfigurationDetails = new List <InConfigurationDetails>(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { inConfigurationDetails = (from c in db.InConfiguration from e in db.InUsers .Where(x => x.Id == c.EmpId).DefaultIfEmpty() select new InConfigurationDetails { name = c.Name, ConfId = c.ConfId, EmpId = c.EmpId, EmpName = e.Username, Branch = c.Branch, UserCount = c.UserCount, CreatedBy = c.CreatedBy, CreatedDate = c.CreatedDate, IsActive = c.IsActive }).Where(x => x.IsActive == true).OrderByDescending(x => x.CreatedDate).ToList(); } return(inConfigurationDetails); } catch (Exception ex) { throw; } }
public List <InSubUserDetails> GetSubUser() { try { List <InSubUserDetails> inSubUserDetails = new List <InSubUserDetails>(); List <InSubUser> inSubUsers = new DB_A3E3FF_scampus2020Context().InSubUser.ToList(); List <InUsers> inUsers = new DB_A3E3FF_scampusMaster2020Context().InUsers.ToList(); List <InConfiguration> inConfigurations = new DB_A3E3FF_scampusMaster2020Context().InConfiguration.ToList(); //using (DB_A3E3FF_scampus2020Context db = DB_A3E3FF_scampus2020Context()) //{ inSubUserDetails = (from b in inSubUsers from e in inUsers .Where(x => x.Id == b.EmpId).DefaultIfEmpty() from c in inConfigurations .Where(x => x.ConfId == b.ConfigId).DefaultIfEmpty() select new InSubUserDetails { Id = b.Id, ConfigId = b.ConfigId, ConfigName = c.Name, EmpName = e.Username, EmpId = b.EmpId, SubUserName = b.SubUserName, CreatedBy = b.CreatedBy, CreatedDate = b.CreatedDate, IsActive = b.IsActive }).Where(x => x.IsActive == true).OrderByDescending(x => x.CreatedDate).ToList(); return(inSubUserDetails); //} } catch (Exception ex) { throw ex; } }
public Result DeleteConfigurationMaster(string ConfigId) { try { using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { var data = db.ConfigurationMaster.Where(x => x.ConfigId.ToString() == ConfigId).FirstOrDefault(); data.IsActive = false; var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Configuration Added Successfully ..!" }); } else { return(new Result { StatusCode = -1, Message = "Configuration Failed ..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public List <InBranchDetails> GetBranch() { try { List <InBranchDetails> inBranchDetails = new List <InBranchDetails>(); List <InBranch> inBranches = new DB_A3E3FF_scampus2020Context().InBranch.ToList(); List <user> inUsers = new DB_A3E3FF_scampusMaster2020Context().InUsers.Where(x => x.IsActive == true).Select(x => new user { EmpId = x.Id, EmpName = x.Username }).ToList(); List <user> inusers1 = new DB_A3E3FF_scampus2020Context().AdminUsers.Where(x => x.Status == true).Select(x => new user { EmpId = x.Userid, EmpName = x.Username }).ToList(); inUsers.AddRange(inusers1); List <ConfigurationMaster> inConfigurations = new DB_A3E3FF_scampusMaster2020Context().ConfigurationMaster.ToList(); //using (DB_A3E3FF_scampus2020Context db = DB_A3E3FF_scampus2020Context()) //{ inBranchDetails = (from b in inBranches from e in inUsers .Where(x => x.EmpId == b.EmpId).DefaultIfEmpty() from c in inConfigurations .Where(x => x.ConfigId == b.ConfigId).DefaultIfEmpty() select new InBranchDetails { BranchId = b.BranchId, BranchName = b.BranchName, Location = b.Location, Address = b.Address, ContactNumber1 = b.ContactNumber1, ContactNumber2 = b.ContactNumber2, Email = b.Email, ContactPerson = b.ContactPerson, BranchCode = b.BranchCode, Gstin = b.Gstin, State = b.State, District = b.District, Smsapiurl = b.Smsapiurl, Apikey = b.Apikey, SenderId = b.SenderId, BranchLogo = b.BranchLogo, PrintHeaderFile = b.PrintHeaderFile, PrintFooterFile = b.PrintFooterFile, ConfigId = b.ConfigId, EmpName = e.EmpName, EmpId = b.EmpId, ConfigName = c.ConfigName, CreatedBy = b.CreatedBy, CreatedDate = b.CreatedDate, IsActive = b.IsActive }).Where(x => x.IsActive == true).OrderByDescending(x => x.CreatedDate).ToList(); return(inBranchDetails); //} } catch (Exception ex) { throw ex; } }
public Result UpdateSubUser(subUserDetails inSubUser) { try { int?count = 0; using (DB_A3E3FF_scampusMaster2020Context db1 = new DB_A3E3FF_scampusMaster2020Context()) { count = db1.InConfiguration.Where(x => x.ConfId == inSubUser.ConfigId && x.EmpId == inSubUser.EmpId).Select(x => x.Branch).FirstOrDefault(); } InBranch inBranch1 = new InBranch(); using (DB_A3E3FF_scampus2020Context db = new DB_A3E3FF_scampus2020Context()) { var Bcount = db.InSubUser.Where(x => x.ConfigId == inSubUser.ConfigId && x.EmpId == inSubUser.EmpId && x.Id != inSubUser.Id).Count(); if (Bcount < count) { var data = db.InSubUser.Where(x => x.Id == inSubUser.Id && x.EmpId == inSubUser.EmpId).FirstOrDefault(); data.ConfigId = inSubUser.ConfigId; data.SubUserName = inSubUser.SubUserName; data.EmpId = inSubUser.EmpId; data.EmailId = inSubUser.EmailId; data.UpdatedBy = inSubUser.CreatedBy; data.UpdatedDate = inSubUser.CreatedDate; var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Sub User Updated successfully..!" }); } else { return(new Result { StatusCode = -1, Message = "Sub User Failed..!" }); } } else { return(new Result { StatusCode = -1, Message = "Sub User count cannot be more than Configuration Count.!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public Result AddSubUser(subUserDetails inSubUser) { try { int?count = 0; using (DB_A3E3FF_scampusMaster2020Context db1 = new DB_A3E3FF_scampusMaster2020Context()) { count = db1.InConfiguration.Where(x => x.ConfId == inSubUser.ConfigId && x.EmpId == inSubUser.EmpId).Select(x => x.UserCount).FirstOrDefault(); } InSubUser inSubUser1 = new InSubUser(); using (DB_A3E3FF_scampus2020Context db = new DB_A3E3FF_scampus2020Context()) { var Bcount = db.InSubUser.Where(x => x.ConfigId == inSubUser.ConfigId && x.EmpId == inSubUser.EmpId).Where(x => x.IsActive == true).Count(); if (Bcount < count) { inSubUser1.ConfigId = inSubUser.ConfigId; inSubUser1.EmpId = inSubUser.EmpId; inSubUser1.SubUserName = inSubUser.SubUserName; inSubUser1.CreatedBy = inSubUser.CreatedBy; inSubUser1.CreatedDate = inSubUser.CreatedDate; inSubUser1.EmailId = inSubUser.EmailId; db.InSubUser.Add(inSubUser1); var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Sub User Added successfully..!" }); } else { return(new Result { StatusCode = -1, Message = "Sub User Failed..!" }); } } else { return(new Result { StatusCode = -1, Message = "Sub User count cannot be more than Configuration Count.!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public Result AddConfigurationMaster(ConfigurationMaster configurationMaster) { try { ConfigurationMaster configurationMaster1 = new ConfigurationMaster(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { configurationMaster1.ConfigName = configurationMaster.ConfigName; configurationMaster1.NoOfBranches = configurationMaster.NoOfBranches; configurationMaster1.NoOfStaff = configurationMaster.NoOfStaff; configurationMaster1.NoOfStudent = configurationMaster.NoOfStudent; configurationMaster1.NoOfVideoConferenceDaily = configurationMaster.NoOfVideoConferenceDaily; configurationMaster1.MaxDurationOfConference = configurationMaster.MaxDurationOfConference; configurationMaster1.MaxNoOfVideoRecording = configurationMaster.MaxNoOfVideoRecording; configurationMaster1.MaxParticipantInConference = configurationMaster.MaxParticipantInConference; configurationMaster1.BaseUrl = configurationMaster.BaseUrl; configurationMaster1.BrandLogo = configurationMaster.BrandLogo; configurationMaster1.PageTitle = configurationMaster.PageTitle; configurationMaster1.AccoutExpiryDate = configurationMaster.AccoutExpiryDate; configurationMaster1.BrandName = configurationMaster.BrandName; configurationMaster1.BrandCode = configurationMaster.BrandCode; configurationMaster1.PageTitle = configurationMaster.PageTitle; configurationMaster1.UpdatedBy = configurationMaster.CreatedBy; configurationMaster1.UpdatedDate = configurationMaster.CreatedDate; db.ConfigurationMaster.Add(configurationMaster1); var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Added Successfully..!" }); } else { return(new Result { StatusCode = -1, Message = "Added Failed..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public Result UpdateConfigurationMaster(ConfigurationMaster configurationMaster) { try { using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { var data = db.ConfigurationMaster.Where(x => x.ConfigId == configurationMaster.ConfigId).FirstOrDefault(); data.ConfigName = configurationMaster.ConfigName; data.NoOfBranches = configurationMaster.NoOfBranches; data.NoOfStaff = configurationMaster.NoOfStaff; data.NoOfStudent = configurationMaster.NoOfStudent; data.NoOfVideoConferenceDaily = configurationMaster.NoOfVideoConferenceDaily; data.MaxDurationOfConference = configurationMaster.MaxDurationOfConference; data.MaxNoOfVideoRecording = configurationMaster.MaxNoOfVideoRecording; data.MaxParticipantInConference = configurationMaster.MaxParticipantInConference; data.BaseUrl = configurationMaster.BaseUrl; data.BrandLogo = configurationMaster.BrandLogo; data.PageTitle = configurationMaster.PageTitle; data.AccoutExpiryDate = configurationMaster.AccoutExpiryDate; data.BrandName = configurationMaster.BrandName; data.BrandCode = configurationMaster.BrandCode; data.PageTitle = configurationMaster.PageTitle; data.UpdatedBy = configurationMaster.CreatedBy; data.UpdatedDate = configurationMaster.CreatedDate; var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Configuration Updated Successfully ..!" }); } else { return(new Result { StatusCode = -1, Message = "Configuration Failed ..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public List <ConfigurationMaster> GetConfigurationMasters() { try { List <ConfigurationMaster> configurationMasters = new List <ConfigurationMaster>(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { configurationMasters = db.ConfigurationMaster.Where(x => x.IsActive == true).ToList(); } return(configurationMasters); } catch (Exception ex) { throw ex; } }
public List <InUsers> GetUsers() { try { List <InUsers> inUsers = new List <InUsers>(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { inUsers = db.InUsers.Where(x => x.IsActive == true).OrderByDescending(x => x.CreatedDate).ToList(); return(inUsers); } } catch (Exception ex) { throw ex; } }
public List <configDDL> GetConfigurationDDl() { try { List <configDDL> configDDLs = new List <configDDL>(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { configDDLs = db.ConfigurationMaster.Where(x => x.IsActive == true).Select(x => new configDDL { configName = x.ConfigName, configId = x.ConfigId }).ToList(); } return(configDDLs); } catch (Exception ex) { throw ex; } }
public Result AddUser(userDetails inUsers) { try { InUsers inUsers1 = new InUsers(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { inUsers1.Username = inUsers.Username; inUsers1.Password = inUsers.Password; inUsers1.Role = inUsers.Role; inUsers1.CreatedBy = inUsers.CreatedBy; inUsers1.CreatedById = inUsers.CreatedById; inUsers1.EmailId = inUsers.EmailId; inUsers1.AccountStatus = inUsers.AccountStatus; inUsers1.CreatedDate = DateTime.Now; inUsers1.Configuration = inUsers.ConfiguratoinId; inUsers1.BaseUrl = inUsers1.BaseUrl; db.InUsers.Add(inUsers1); var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "User Added Successfully ..!" }); } else { return(new Result { StatusCode = -1, Message = "User Failed ..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public Result UpdateUser(userDetails inUsers) { try { using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { var data = db.InUsers.Where(x => x.Id == inUsers.Id).FirstOrDefault(); data.Username = inUsers.Username; data.Password = inUsers.Password; data.EmailId = inUsers.EmailId; data.Configuration = inUsers.ConfiguratoinId; data.AccountStatus = inUsers.AccountStatus; data.Role = inUsers.Role; data.CreatedById = inUsers.CreatedById; data.UpdatedBy = "Admin"; data.UpdatedDate = DateTime.Now; data.BaseUrl = inUsers.BaseUrl; var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "User Updated Successfully ..!" }); } else { return(new Result { StatusCode = -1, Message = "User Failed ..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public Result AddConfiguration(ConfigurationDetail inConfiguration) { try { InConfiguration inConfiguration1 = new InConfiguration(); using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { inConfiguration1.EmpId = inConfiguration.EmpId; inConfiguration1.Name = inConfiguration.Name; inConfiguration1.Branch = inConfiguration.Branch; inConfiguration1.UserCount = inConfiguration.UserCount; inConfiguration1.CreatedBy = "Admin"; inConfiguration1.CreatedDate = DateTime.Now; db.InConfiguration.Add(inConfiguration1); var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Configuration Added Successfully ..!" }); } else { return(new Result { StatusCode = -1, Message = "Configuration Failed ..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public Result UpdateConfiguration(ConfigurationDetail inConfiguration) { try { using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { var data = db.InConfiguration.Where(x => x.ConfId == inConfiguration.ConfId).FirstOrDefault(); data.EmpId = inConfiguration.EmpId; data.Name = inConfiguration.Name; data.Branch = inConfiguration.Branch; data.UserCount = inConfiguration.UserCount; data.UpdatedBy = "Admin"; data.UpdatedDate = DateTime.Now; var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Configuration Updated Successfully ..!" }); } else { return(new Result { StatusCode = -1, Message = "Configuration Failed ..!" }); } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public UserCred Authenticate(UserCred userCred) { try { UserCred users = new UserCred(); if (userCred.IsSuperAdmin == true) { using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { var user = db.InUsers.Where(x => x.Username == userCred.Username && x.Password == userCred.Password && x.IsActive == true).FirstOrDefault(); //if user not found if (user == null) { return(null); } else { //if user found var confdata = db.ConfigurationMaster.Where(x => x.ConfigId.ToString() == user.Configuration.ToString() && x.BaseUrl == userCred.BaseUrl && x.IsActive == true).FirstOrDefault(); if (confdata != null) { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Key); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.Username), new Claim(ClaimTypes.Role, user.Role), new Claim(ClaimTypes.Version, "3.1") }), Expires = DateTime.UtcNow.AddMinutes(15), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); users.Token = tokenHandler.WriteToken(token); users.Role = user.Role; users.userId = user.Id; users.ConfigId = user.Configuration; users.BaseUrl = user.BaseUrl; } else { return(null); } } } } else { List <ConfigurationMaster> configurationMaster = new DB_A3E3FF_scampusMaster2020Context().ConfigurationMaster.Where(x => x.IsActive == true).ToList(); using (DB_A3E3FF_scampus2020Context db1 = new DB_A3E3FF_scampus2020Context()) { var user = db1.AdminUsers.Where(x => x.Username == userCred.Username && x.Password == userCred.Password && x.Status == true).FirstOrDefault(); //if user not found if (user == null) { return(null); } else { var confiData = configurationMaster.Where(x => x.ConfigId == user.ConfigSettings && x.BaseUrl == userCred.BaseUrl && x.IsActive == true).FirstOrDefault(); //if user found if (confiData != null) { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Key); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.Username), new Claim(ClaimTypes.Role, user.Role), new Claim(ClaimTypes.Version, "3.1") }), Expires = DateTime.UtcNow.AddMinutes(15), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); users.Token = tokenHandler.WriteToken(token); users.Role = user.Role; users.userId = user.Userid; users.BaseUrl = user.Baseurl; users.ConfigId = user.ConfigSettings; } else { return(null); } } return(users); } } return(users); } catch (Exception ex) { throw ex; } }
public Result UpdateBranch(InBranchDetails inBranch) { try { int?count = 0; using (DB_A3E3FF_scampusMaster2020Context db1 = new DB_A3E3FF_scampusMaster2020Context()) { count = db1.ConfigurationMaster.Where(x => x.ConfigId == inBranch.ConfigId).Select(x => x.NoOfBranches).FirstOrDefault(); } using (DB_A3E3FF_scampus2020Context db = new DB_A3E3FF_scampus2020Context()) { var Bcount = db.InBranch.Where(x => x.ConfigId == inBranch.ConfigId && x.EmpId == inBranch.EmpId).Count(); //if (Bcount < count) //{ var inBranch1 = db.InBranch.Where(x => x.BranchId == inBranch.BranchId && x.EmpId == inBranch.EmpId).FirstOrDefault(); inBranch1.BranchName = inBranch.BranchName; inBranch1.Location = inBranch.Location; inBranch1.Address = inBranch.Address; inBranch1.ContactNumber1 = inBranch.ContactNumber1; inBranch1.ContactNumber2 = inBranch.ContactNumber2; inBranch1.Email = inBranch.Email; inBranch1.ContactPerson = inBranch.ContactPerson; inBranch1.BranchCode = inBranch.BranchCode; inBranch1.Gstin = inBranch.Gstin; inBranch1.State = inBranch.State; inBranch1.District = inBranch.District; inBranch1.Smsapiurl = inBranch.Smsapiurl; inBranch1.Apikey = inBranch.Apikey; inBranch1.SenderId = inBranch.SenderId; inBranch1.BranchLogo = inBranch.BranchLogo; inBranch1.PrintHeaderFile = inBranch.PrintHeaderFile; inBranch1.PrintFooterFile = inBranch.PrintFooterFile; inBranch1.UpdatedBy = inBranch.CreatedBy; inBranch1.UpdatedDate = inBranch.CreatedDate; inBranch1.EmpId = inBranch.EmpId; inBranch1.ConfigId = inBranch.ConfigId; var result = db.SaveChanges(); if (result == 1) { return(new Result { StatusCode = 1, Message = "Branch Updated successfully..!" }); } else { return(new Result { StatusCode = -1, Message = "Branch Failed..!" }); } //} //else //{ // return new Result { StatusCode = -1, Message = "Branch count cannot be more than Configuration Count.!" }; //} } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }
public List <AdminUserDetails> GetAdminUsers(string role) { try { List <AdminUserDetails> adminUsers = new List <AdminUserDetails>(); List <ConfigurationMaster> configurationMasters = new DB_A3E3FF_scampusMaster2020Context().ConfigurationMaster.Where(x => x.IsActive == true).ToList(); List <AdminUsers> adminUsers1 = new DB_A3E3FF_scampus2020Context().AdminUsers.Where(x => x.Status == true).ToList(); List <InUsers> inUsers = new DB_A3E3FF_scampusMaster2020Context().InUsers.Where(x => x.IsActive == true).ToList(); List <AdminUserDetails> user = new List <AdminUserDetails>(); //DB_A3E3FF_scampus2020Context().AdminUsers.Where(x => x.Role == "Admin" && x.Status == true).ToList(); using (DB_A3E3FF_scampus2020Context db = new DB_A3E3FF_scampus2020Context()) { user = (from a in adminUsers1 from c in configurationMasters .Where(x => x.ConfigId == a.ConfigSettings).DefaultIfEmpty() select new AdminUserDetails { Userid = a.Userid, Username = a.Username, Password = a.Password, EmailId = a.EmailId, ConfigSettings = a.ConfigSettings, ConfigName = c.ConfigName, Role = a.Role, Status = a.Status, AccountStatus = a.AccountStatus, CreatedBy = a.CreatedBy, CreatedDate = a.CreatedDate }).Where(x => x.Status == true && x.Role == "Admin").ToList(); } if (role == "Super Admin") { adminUsers = (from a in inUsers from c in configurationMasters .Where(x => x.ConfigId == a.Configuration).DefaultIfEmpty() select new AdminUserDetails { Userid = a.Id, Username = a.Username, Password = a.Password, EmailId = a.EmailId, ConfigSettings = a.Configuration, ConfigName = c.ConfigName, Status = a.IsActive, Role = a.Role, Baseurl = a.BaseUrl, AccountStatus = a.AccountStatus, CreatedBy = a.CreatedBy, CreatedDate = a.CreatedDate }).OrderByDescending(x => x.CreatedDate).Where(x => x.Status == true).ToList(); adminUsers.AddRange(user); } else if (role == "Admin") { adminUsers = (from a in adminUsers1 from c in configurationMasters .Where(x => x.ConfigId == a.ConfigSettings).DefaultIfEmpty() select new AdminUserDetails { Userid = a.Userid, Username = a.Username, Password = a.Password, EmailId = a.EmailId, ConfigSettings = a.ConfigSettings, ConfigName = c.ConfigName, Status = a.Status, Role = a.Role, Baseurl = a.Baseurl, AccountStatus = a.AccountStatus, CreatedBy = a.CreatedBy, CreatedDate = a.CreatedDate }).OrderByDescending(x => x.CreatedDate).Where(x => x.Status == true).ToList(); } //adminUsers = (from a in adminUsers1 // from c in configurationMasters // .Where(x => x.ConfigId == a.ConfigSettings).DefaultIfEmpty() // select new AdminUserDetails // { // Userid = a.Userid, // Username = a.Username, // Password = a.Password, // EmailId = a.EmailId, // ConfigSettings = a.ConfigSettings, // ConfigName = c.ConfigName, // Status = a.Status, // AccountStatus = a.AccountStatus, // CreatedBy = a.CreatedBy, // CreatedDate = a.CreatedDate // }).OrderByDescending(x => x.CreatedDate).Where(x => x.Status == true).ToList(); // } return(adminUsers); } catch (Exception ex) { throw ex; } }
public Result Login(string username, string password, bool?Role, string baseusrl) { try { if (Role == true) { using (DB_A3E3FF_scampusMaster2020Context db = new DB_A3E3FF_scampusMaster2020Context()) { var data = db.InUsers.Where(x => x.Username == username && x.Password == password && x.BaseUrl == baseusrl && x.IsActive == true).FirstOrDefault(); if (data != null) { var confdata = db.ConfigurationMaster.Where(x => x.ConfigId.ToString() == data.Configuration.ToString() && x.IsActive == true).FirstOrDefault(); if (confdata != null) { return(new Result { StatusCode = 1, Message = "Login success ..!" }); } else { return(new Result { StatusCode = -1, Message = "Login Failed" }); } } else { return(new Result { StatusCode = -1, Message = "Login Failed" }); } } } else { List <ConfigurationMaster> configurationMaster = new DB_A3E3FF_scampusMaster2020Context().ConfigurationMaster.Where(x => x.IsActive == true).ToList(); using (DB_A3E3FF_scampus2020Context db1 = new DB_A3E3FF_scampus2020Context()) { var data = db1.AdminUsers.Where(x => x.Username == username && x.Password == password && x.Baseurl == baseusrl && x.Status == true).FirstOrDefault(); if (data != null) { var confdata = configurationMaster.Where(x => x.ConfigId.ToString() == data.ConfigSettings.ToString() && x.IsActive == true).FirstOrDefault(); if (confdata != null) { return(new Result { StatusCode = 1, Message = "Login success ..!" }); } else { return(new Result { StatusCode = -1, Message = "Login Failed" }); } } else { return(new Result { StatusCode = -1, Message = "Login Failed" }); } } } } catch (Exception ex) { return(new Result { StatusCode = -1, Message = ex.Message }); throw ex; } }