示例#1
0
        public ActionResult Update(Technology technology)
        {
            ApiResult <Technology> apiResult;

            if (ModelState.IsValid)
            {
                if (technology.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        _technologyRepository.Update(technology);
                        _unitOfWork.Commit();
                        return(technology);
                    }, "Technology updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        _technologyRepository.Create(technology);
                        _unitOfWork.Commit();
                        return(technology);
                    }, "Technology created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <Technology>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }