public List <Favourite> GetCompanyFavourite() { using (var ctx = new RbDbContext()) { return(ctx.Favourites.Where(x => x.IsCompany == true).ToList()); } }
public string EditUser(string id, ApplicationUser applicationUser) { try { var ctx = new RbDbContext(); var user = ctx.Users.FirstOrDefault(u => u.UserName.ToLower() == applicationUser.UserName.ToLower()); if (user != null) { user.FirstName = applicationUser.FirstName; user.LastName = applicationUser.LastName; user.Position = applicationUser.Position; user.Email = applicationUser.Email; user.Role = applicationUser.Role; user.GeoCode = applicationUser.GeoCode; user.Org = applicationUser.Org; user.ReceiveEmailAlert = applicationUser.ReceiveEmailAlert; } ctx.SaveChanges(); return(Constant.UserAdmin.Result.Updated); } catch (Exception ex) { IMS.Logger.Logger.Fatal(ex.Message, ex); return("failed"); } }
public List <Favourite> GetFavourite(string userId) { using (var ctx = new RbDbContext()) { return(ctx.Favourites.Where(x => x.UserId == userId).ToList()); } }
public ApplicationUser GetUserByEmail(string email) { using (var ctx = new RbDbContext()) { return(ctx.Users.Where(p => p.Email.ToLower() == email.ToLower()).FirstOrDefault()); } }
public List <ApplicationUser> GetActiveUsers() { using (var ctx = new RbDbContext()) { return(ctx.Users.ToList()); } }
public string GetKSAPassword(string userId) { using (var ctx = new RbDbContext()) { var item = ctx.KSAPasswords.Where(i => i.KSA_UserId == userId).ToList().FirstOrDefault(); if (item != null) { return(item.GetType().GetProperty("KSA_Password").GetValue(item, null).ToString()); } return(string.Empty); } }
public string DeleteFavourite(int favouriteId) { using (var ctx = new RbDbContext()) { var favourites = ctx.Favourites.FirstOrDefault(x => x.Id == favouriteId); if (favourites != null) { ctx.Favourites.Remove(favourites); ctx.SaveChanges(); return("Record has been successfully deleted"); } return("No data found"); } }
public string RenameFavourite(int favouriteId, string favouriteText) { using (var ctx = new RbDbContext()) { var favourite = ctx.Favourites.FirstOrDefault(x => x.Id == favouriteId); if (favourite != null) { favourite.Title = favouriteText; ctx.Entry(favourite).State = EntityState.Modified; ctx.SaveChanges(); return("Updated successfully"); } return("No data found"); } }
public string RemoveUser(string id) { try { var ctx = new RbDbContext(); var user = ctx.Users.FirstOrDefault(u => u.UserName.ToLower() == id.ToLower()); ctx.Users.Remove(user); ctx.SaveChanges(); return("Removed successfully"); } catch (Exception ex) { IMS.Logger.Logger.Fatal(ex.Message, ex); return(ex.Message); } }
public string SaveFavourite(Favourite favourite) { using (var ctx = new RbDbContext()) { var result = ctx.Favourites.FirstOrDefault(x => x.UserId == favourite.UserId && x.NavName == favourite.NavName); if (result == null) { ctx.Favourites.Add(favourite); } else { result.IsCompany = favourite.IsCompany; result.OnClick = favourite.OnClick; result.Params = favourite.Params; result.Title = favourite.Title; } ctx.SaveChanges(); return("Saved successfully"); } }
public ApplicationUser GetActiveUser(string userId) { try { using (var ctx = new RbDbContext()) { return(ctx.Users.FirstOrDefault(p => p.UserName.ToLower() == userId.ToLower())); } } catch (InvalidOperationException exception) { IMS.Logger.Logger.Fatal(exception.Message, exception); return(new ApplicationUser() { Email = "*****@*****.**", FirstName = "Exception", LastName = "User", UserName = "******" }); } }
public int AddUserActivity(string userName) { try { using (var ctx = new RbDbContext()) { var userActivity = new UserActivity() { UserId = userName, LoginTime = DateTime.Now }; ctx.UserActivities.Add(userActivity); ctx.SaveChanges(); } return(1); } catch (Exception ex) { IMS.Logger.Logger.Fatal(ex.Message, ex); return(0); } }