Ejemplo n.º 1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public JsonResult Update(Relation entity)
        {
            ModelState.Remove("CreatedTime");
            ModelState.Remove("UpdatedTime");
            ModelState.Remove("IsDelete");
            if (ModelState.IsValid)
            {
                var model = IRelationService.Find(entity.ID);
                if (model == null || (model != null && model.IsDelete))
                {
                    return(DataErorrJResult());
                }

                if (IRelationService.IsExits(x => x.Name == entity.Name && x.ID != entity.ID))
                {
                    return(JResult(Core.Code.ErrorCode.store_city__namealready_exist, ""));
                }

                model.Name = entity.Name;
                var result = IRelationService.Update(model);
                return(JResult(result));
            }
            else
            {
                return(ParamsErrorJResult(ModelState));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(RelationViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    service.Update(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }
                var employees = employeeService.GetEmployeeSelectListItems().Select(x => new {
                    Id   = x.Id,
                    Name = x.LastName + " - " + x.FirstName
                }).ToList();
                ViewBag.Employees = new SelectList(employees, "Id", "Name");

                var employees1 = employeeService.GetEmployeeSelectListItems1().Select(x => new {
                    Id   = x.Id,
                    Name = x.LastName + " - " + x.FirstName
                }).ToList();
                ViewBag.Employees1 = new SelectList(employees, "Id", "Name");
                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 3
0
        public IActionResult Update(Relation relation)
        {
            var result = _relationService.Update(relation);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }