예제 #1
0
 public IPagedList <UserListViewModel> GetUserList(SearchViewModel search)
 {
     try
     {
         using (db = new PMSContext())
         {
             search.PageNumber = search.PageNumber <= 0 ? 1 : search.PageNumber;
             search.PageSize   = search.PageSize <= 0 ? 1 : search.PageSize;
             return(db.PMSuser.Where(x => !x.IsDeleted).Select(x => new UserListViewModel
             {
                 CreatedOn = x.CreatedOn,
                 DOB = x.DOB,
                 Email = x.Email,
                 Name = x.Name,
                 Id = x.Id,
                 Phone = x.Phone,
                 UserName = x.UserName
             }).OrderByDescending(x => x.CreatedOn).ToPagedList(search.PageNumber, search.PageSize));
         }
     }
     catch (Exception ex)
     {
         errorService.SaveError(ex);
         return(null);
     }
 }
예제 #2
0
 public void SaveError(Exception ex)
 {
     using (db = new PMSContext())
     {
         error = new ErrorLog
         {
             CreatedOn  = DateTime.Now,
             HelpLink   = ex.HelpLink,
             HResult    = ex.HResult,
             Message    = ex.Message,
             Source     = ex.Source,
             StackTrace = ex.StackTrace
         };
         db.ErrorLog.Add(error);
         db.SaveChanges();
     }
 }
예제 #3
0
 public bool Delete(Guid id)
 {
     try
     {
         using (db = new PMSContext())
         {
             db.PMSuser.Where(x => x.Id == id).FirstOrDefault().IsDeleted = true;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         errorService.SaveError(ex);
         return(false);
     }
 }
예제 #4
0
        public bool Verify(RegisterViewModel model)
        {
            try
            {
                using (db = new PMSContext())
                {
                    security = new SecurityServices();
                    string pass = security.Encrypt(model.password, true);

                    var user = db.PMSuser.Where(x => (x.UserName == model.user || x.Email == model.user || x.Phone == model.user) && x.Password == pass && !x.IsDeleted).FirstOrDefault();
                    if (user != null)
                    {
                        AddCookie(user);
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorService.SaveError(ex);
                return(false);
            }
        }
예제 #5
0
 public ErrorLogServices()
 {
     db = new PMSContext();
 }
예제 #6
0
 public CommonGeneric()
 {
     db           = new PMSContext();
     errorService = new ErrorLogServices();
 }