コード例 #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));
        }
コード例 #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));
            }
        }
コード例 #3
0
 public static void UpdateTechLine(this TechLine techLine, TechLineViewModel techLineViewModel)
 {
     techLine.ID   = techLineViewModel.ID;
     techLine.Name = techLineViewModel.Name;
 }
コード例 #4
0
ファイル: TechLineService.cs プロジェクト: jerryho83/tedu-cms
 public void Update(TechLine techLine)
 {
     _techLineRepository.Update(techLine);
 }
コード例 #5
0
ファイル: TechLineService.cs プロジェクト: jerryho83/tedu-cms
 public TechLine Add(TechLine techLine)
 {
     return(_techLineRepository.Add(techLine));
 }