コード例 #1
0
        public ActionResult Edit(int id)
        {
            WorkcenterDTO workcenterDto = new WorkcenterDTO();

            try
            {
                Workcenter workcenter = workcenterCrudService.Get(id);
                if (workcenter == null)
                {
                    logger.Error($"HttpNotFound! Url:{System.Web.HttpContext.Current.Request.UrlReferrer}");

                    //Dictionary<string, string> statys = new Dictionary<string, string>
                    //{
                    //    ["statys"] = "HttpNotFound"
                    //};

                    //return Json(statys, JsonRequestBehavior.AllowGet);
                    return(HttpNotFound());
                }
                else
                {
                    workcenterDto = AutoMapperWebUtil.WorkcenterEntitiesToDto(workcenter);
                }
            }
            catch (ValidationException ex)
            {
                ControllerExtension.ActionsOnException(logger, ex, ModelState);
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
            // workcenterViewModel.ModelState = this.ModelState;
            return(Json(workcenterDto, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
 public ActionResult Add(WorkcenterDTO workcenterDto)
 {
     try
     {
         //workcenterViewModel.ModelState = this.ModelState;
         if (ModelState.IsValid)
         {
             var workcenterDTO = AutoMapperWebUtil.WorkcenterDtoToEntities(workcenterDto);
             int workcenterId  = workcenterCrudService.Add(workcenterDTO);
             return(RedirectToAction("Index"));
         }
     }
     catch (ValidationException ex)
     {
         ControllerExtension.ActionsOnException(logger, ex, ModelState);
         return(Json(ex, JsonRequestBehavior.AllowGet));
     }
     //workcenterViewModel.ModelState = this.ModelState;
     return(Json(workcenterDto, JsonRequestBehavior.AllowGet));
 }
コード例 #3
0
        public ActionResult DeleteWorkcenter(int id)
        {
            Workcenter workcenter = workcenterCrudService.Get(id);

            try
            {
                if (workcenter != null)
                {
                    workcenterCrudService.Delete(id);
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (ValidationException ex)
            {
                ControllerExtension.ActionsOnException(logger, ex, ModelState);
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public ActionResult Delete(int id)
        {
            WorkcenterDTO workcenterDto;
            Workcenter    workcenter = workcenterCrudService.Get(id);

            try
            {
                if (workcenter == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    workcenterDto = AutoMapperWebUtil.WorkcenterEntitiesToDto(workcenter);
                }
            }
            catch (ValidationException ex)
            {
                ControllerExtension.ActionsOnException(logger, ex, ModelState);
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
            return(Json(workcenterDto, JsonRequestBehavior.AllowGet));
        }