public ActionResult SaveOrUpdate(Domain.DTO.JobPost JobPost) { try { using (var db = new IranMarketerContext()) { var current = db.JobPosts.FirstOrDefault(x => x.PartyId == JobPost.PartyId && x.Id == JobPost.Id); var entity = ObjectMapper.BaseConverter .ConvertSourceToDest <Domain.DTO.JobPost, IranMarketer.Domain.Entity.JobPost> (JobPost); if (current != null) { entity.Id = current.Id; } entity.Modified = DateTime.Now; entity.Created = current?.Created ?? DateTime.Now; entity.CreatedBy = current?.CreatedBy ?? JobPost.UserName; entity.ModifiedBy = JobPost.UserName; JobPostRepository.SaveOrUpdate(entity); return(this.Json(this.SuccessApiResponse, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(ErrorApiResponse, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetJobPostById(Domain.DTO.JobPost JobPost) { try { var all = JobPostRepository.GetKey(JobPost.Id); var dto = ObjectMapper.BaseConverter .ConvertSourceToDest <IranMarketer.Domain.Entity.JobPost, Domain.DTO.JobPost>(all); SuccessApiResponse.Result = dto; return(Json(SuccessApiResponse, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(ErrorApiResponse, JsonRequestBehavior.AllowGet)); } }