Example #1
0
        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));
        }
Example #2
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));
            }
        }
Example #3
0
 public static void UpdateTechLine(this TechLine techLine, TechLineViewModel techLineViewModel)
 {
     techLine.ID   = techLineViewModel.ID;
     techLine.Name = techLineViewModel.Name;
 }
Example #4
0
 public void Update(TechLine techLine)
 {
     _techLineRepository.Update(techLine);
 }
Example #5
0
 public TechLine Add(TechLine techLine)
 {
     return(_techLineRepository.Add(techLine));
 }