public DirectoryUnitOfWork(DirectoryEntities context = null) { _context = context ?? new DirectoryEntities(); AuthenticationRepository = new AuthenticationRepository(_context); MandatorRepository = new MandatorRepository(_context); SessionRepository = new SessionRepository(_context); }
public List <CategorySetupViewModel> GetAllCategories() { using (var con = new DirectoryEntities()) { var data = con.tblDirectoryCategories .Select(x => new CategorySetupViewModel() { DirectoryCategoryId = x.DirectoryCategoryId, DirectoryCategoryName = x.DirectoryCategoryName, }).ToList(); return(data); } }
public CategorySetupViewModel GetCategoryById(int?id) { using (var con = new DirectoryEntities()) { var data = con.tblDirectoryCategories.Where(x => x.DirectoryCategoryId == id) .Select(x => new CategorySetupViewModel() { DirectoryCategoryId = x.DirectoryCategoryId, DirectoryCategoryName = x.DirectoryCategoryName, }).FirstOrDefault(); return(data); } }
public ActionResult GetDirectorySubCategoryById(int id) { List <SelectListItem> subCatList = new List <SelectListItem>(); using (DirectoryEntities db = new DirectoryEntities()) { var catList = db.tblDirectorySubCategories.Where(x => x.DirectoryCategoryId == id).ToList(); foreach (var item in catList) { subCatList.Add(new SelectListItem { Text = item.DirectorySubCategoryName, Value = item.DirectorySubCategoryId.ToString() }); } } return(Json(subCatList, JsonRequestBehavior.AllowGet)); }
public ActionResult GetPalika(int ID) { List <SelectListItem> palikaList = new List <SelectListItem>(); using (DirectoryEntities db = new DirectoryEntities()) { var projectList = db.tblPalikas.Where(x => x.DistrictId == ID).ToList(); foreach (var item in projectList) { palikaList.Add(new SelectListItem { Text = item.PalikaName_Nep, Value = item.PalikaId_val.ToString() }); } } return(Json(palikaList, JsonRequestBehavior.AllowGet)); }
public bool InsertUpdateUserDetails(UserModel model) { try { using (var con = new DirectoryEntities()) { var userId = HttpContext.Current.User.Identity.GetUserId(); var user = con.UsersDetails.Where(x => x.Id == model.Id || x.UserId == userId).FirstOrDefault(); if (user != null) { user.FullName = model.FullName; user.ContactNo = model.PhoneNo; user.Email = model.Email; if (model.Image != null) { user.Image = model.Image; } con.Entry(user).State = System.Data.Entity.EntityState.Modified; } else { UsersDetail usersDetail = new UsersDetail() { Id = Guid.NewGuid(), FullName = model.FullName, ContactNo = model.PhoneNo, UserId = userId, Email = model.Email, Image = model.Image, }; con.UsersDetails.Add(usersDetail); } con.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public UserModel GetUserDetails() { using (var con = new DirectoryEntities()) { var userId = HttpContext.Current.User.Identity.GetUserId(); var email = HttpContext.Current.User.Identity.GetUserName(); var baseUrl = Utility.GetUrlForImage(); var user = con.UsersDetails.Where(x => x.UserId == userId) .Select(x => new UserModel() { Id = x.Id, FullName = x.FullName, PhoneNo = x.ContactNo, Email = email, Image = baseUrl + x.Image, }).FirstOrDefault(); return(user); } }
public bool InsertUpdateSubCategory(SubCategorySetupViewModel model) { try { using (var con = new DirectoryEntities()) { if (model.DirectorySubCategoryId > 0) { var record = con.tblDirectorySubCategories.Where(x => x.DirectorySubCategoryId == model.DirectorySubCategoryId).FirstOrDefault(); if (record != null) { record.DirectorySubCategoryId = model.DirectorySubCategoryId; record.DirectorySubCategoryName = model.DirectorySubCategoryName; record.DirectoryCategoryId = model.DirectoryCategoryId; con.Entry(record).State = System.Data.Entity.EntityState.Modified; } } else { tblDirectorySubCategory subCategory = new tblDirectorySubCategory() { DirectorySubCategoryId = model.DirectorySubCategoryId, DirectorySubCategoryName = model.DirectorySubCategoryName, DirectoryCategoryId = model.DirectoryCategoryId }; //subCategory.CreatedBy = Utility.GetCurrentLoginUser(); subCategory.CreatedDate = DateTime.Now.ToShortDateString().ToString(); con.tblDirectorySubCategories.Add(subCategory); } con.SaveChanges(); return(true); } } catch (Exception) { return(false); } }