private bool ValidateSubjectAreaModel(SubjectAreaViewModel subjectArea) { if (subjectArea.Name == null) { return(false); } return(true); }
public HttpResponseMessage UpdateSubjectArea(SubjectAreaViewModel subjectArea) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "")); } try { var isSubjectAreaUpdated = _subjectAreaService.UpdateSubjectArea(subjectArea); return(Request.CreateResponse(HttpStatusCode.OK, isSubjectAreaUpdated)); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw; } }
public bool SaveSubjectArea(SubjectAreaViewModel subjectArea) { try { if (ValidateSubjectAreaModel(subjectArea)) { var s = new SubjectArea(); s.Name = subjectArea.Name; s.SubjectId = subjectArea.SubjectId; subjectAreaRepository.Add(s); unitOfWork.Save(); } return(true); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw; } }
public bool UpdateSubjectArea(SubjectAreaViewModel model) { try { if (ValidateSubjectAreaModel(model)) { var subjectArea = new SubjectArea(); subjectArea.SubjectAreaId = model.SubjectAreaId; subjectArea.Name = model.Name; subjectArea.SubjectId = model.SubjectId; subjectAreaRepository.Update(subjectArea); unitOfWork.Save(); } return(true); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw; } }
public HttpResponseMessage PostSubjectArea(SubjectAreaViewModel subjectArea) { var isSubjectAreaSaved = _subjectAreaService.SaveSubjectArea(subjectArea); return(Request.CreateResponse(HttpStatusCode.OK, isSubjectAreaSaved)); }