示例#1
0
 public List <Favourite> GetCompanyFavourite()
 {
     using (var ctx = new RbDbContext())
     {
         return(ctx.Favourites.Where(x => x.IsCompany == true).ToList());
     }
 }
示例#2
0
 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");
     }
 }
示例#3
0
 public List <Favourite> GetFavourite(string userId)
 {
     using (var ctx = new RbDbContext())
     {
         return(ctx.Favourites.Where(x => x.UserId == userId).ToList());
     }
 }
示例#4
0
 public ApplicationUser GetUserByEmail(string email)
 {
     using (var ctx = new RbDbContext())
     {
         return(ctx.Users.Where(p => p.Email.ToLower() == email.ToLower()).FirstOrDefault());
     }
 }
示例#5
0
 public List <ApplicationUser> GetActiveUsers()
 {
     using (var ctx = new RbDbContext())
     {
         return(ctx.Users.ToList());
     }
 }
示例#6
0
 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);
     }
 }
示例#7
0
 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");
     }
 }
示例#8
0
 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");
     }
 }
示例#9
0
 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);
     }
 }
示例#10
0
 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");
     }
 }
示例#11
0
 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 = "******"
         });
     }
 }
示例#12
0
 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);
     }
 }