public HttpResponseMessage Details(HttpRequestMessage request, int id) { if (id == 0) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, nameof(id) + " is required.")); } TechLine techLine = _techLineService.GetDetail(id); var techLineViewModel = Mapper.Map <TechLine, TechLineViewModel>(techLine); if (techLine == null) { return(request.CreateErrorResponse(HttpStatusCode.NoContent, "No group")); } return(request.CreateResponse(HttpStatusCode.OK, techLineViewModel)); }
public HttpResponseMessage Create(HttpRequestMessage request, TechLineViewModel techLineViewModel) { if (ModelState.IsValid) { var techLine = new TechLine(); techLine.Name = techLineViewModel.Name; try { var appGroup = _techLineService.Add(techLine); _techLineService.Save(); return(request.CreateResponse(HttpStatusCode.OK, techLineViewModel)); } catch (NameDuplicatedException dex) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, dex.Message)); } } else { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public static void UpdateTechLine(this TechLine techLine, TechLineViewModel techLineViewModel) { techLine.ID = techLineViewModel.ID; techLine.Name = techLineViewModel.Name; }
public void Update(TechLine techLine) { _techLineRepository.Update(techLine); }
public TechLine Add(TechLine techLine) { return(_techLineRepository.Add(techLine)); }