Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> Update(HttpRequestMessage request, TechLineViewModel techLineViewModel)
        {
            if (ModelState.IsValid)
            {
                var appGroup = _techLineService.GetDetail(techLineViewModel.ID);
                try
                {
                    appGroup.UpdateTechLine(techLineViewModel);
                    _techLineService.Update(appGroup);

                    _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));
            }
        }
Esempio n. 3
0
 public static void UpdateTechLine(this TechLine techLine, TechLineViewModel techLineViewModel)
 {
     techLine.ID   = techLineViewModel.ID;
     techLine.Name = techLineViewModel.Name;
 }