コード例 #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 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));
        }