public RecruitmentAgenciesVM Post(RecruitmentAgenciesVM vm, string userId) { using (var db = new LMISEntities()) { try { var id = vm.RecruitmentAgencieID; var checkExist = db.RecruitmentAgencies.Count(c => c.Name == vm.Name && c.RecruitmentAgencieID != vm.RecruitmentAgencieID && c.IsDeleted == null); if (checkExist > 0) { return(null); } if (id > 0) //Update { var tr = db.RecruitmentAgencies .Where(r => r.IsDeleted == null && r.RecruitmentAgencieID == id) .ToList().Single(); tr.Background = vm.Background; tr.Name = vm.Name; tr.LogoPath = string.IsNullOrEmpty(vm.LogoPath)?tr.LogoPath: vm.LogoPath; tr.UpdateUserID = userId; tr.UpdateDate = DateTime.UtcNow; tr.LanguageID = vm.LanguageID; } else //Insert { var tr = new RecruitmentAgency() { Background = vm.Background, Name = vm.Name, LogoPath = vm.LogoPath, PostUserID = userId, PostDate = DateTime.UtcNow, LanguageID = vm.LanguageID }; db.RecruitmentAgencies.Add(tr); db.SaveChanges(); vm.RecruitmentAgencieID = tr.RecruitmentAgencieID; } db.SaveChanges(); } catch (Exception ex) { ExceptionDispatchInfo.Capture(ex).Throw(); } return(vm); } }
public ActionResult Create(RecruitmentAgency recruitmentagency) { if (ModelState.IsValid) { uow.RecruitmentAgencyRepository.Add(recruitmentagency); uow.Save(); return RedirectToAction("Index"); } return View(recruitmentagency); }
public object Update(RecruitmentAgency record) { try { uow.RecruitmentAgencyRepository.Update(record); uow.Save(); return new { Result = "OK" }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }
public ActionResult SelectUserRecruitmentAgent(SelectDeleteRecruitmentAgentViewModel recruitmentAgentViewModel) { ViewBag.RecruitmentAgentIdList = GetRecrutimentAgentIds(); ViewBag.JobsIdList = GetJobIds(); ViewBag.AddressIdList = GetAddressIds(); if (ModelState.IsValid) { var mapper = AutoMapperConfig.Configure(); ModelState.Clear(); RecruitmentAgency recruitmentAgencies = _repositoryEndPointService.GetRecruitmentAgencyById(recruitmentAgentViewModel.RecruitmentAgencyId); recruitmentAgentViewModel = mapper.Map <RecruitmentAgency, SelectDeleteRecruitmentAgentViewModel>(recruitmentAgencies); return(View("SelectDeleteUserRecruitmentAgent ", recruitmentAgentViewModel)); } return(View("SelectDeleteUserRecruitmentAgent ", recruitmentAgentViewModel)); }
public void DeletetRecruitmentAgency(RecruitmentAgency recruitmentAgency) { _unitOfWork.RecruitmentAgencyRepository.Delete(recruitmentAgency); _unitOfWork.SaveChanges(); }
public void InsertRecruitmentAgency(RecruitmentAgency recruitmentAgency) { _unitOfWork.RecruitmentAgencyRepository.Add(recruitmentAgency); _unitOfWork.SaveChanges(); }