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); } }
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(); } }
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); } }
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); } }
public ErrorLogServices() { db = new PMSContext(); }
public CommonGeneric() { db = new PMSContext(); errorService = new ErrorLogServices(); }