示例#1
0
        public JsonResult ClassEdit(int ClassId, ClassModel ClassModel)
        {
            try
            {
                if (ClassId == 0)
                {
                    Core3Base.Infra.Data.Entity.Classs classs = new Core3Base.Infra.Data.Entity.Classs
                    {
                        ClassName = ClassModel.Classs.ClassName,
                        IsActive  = ClassModel.Classs.IsActive,
                    };


                    return(Json(_classService.Add(classs).HttpGetResponse()));
                }
                else
                {
                    var Class = _classService.GetClasssById(ClassId).Result;
                    Class.IsActive  = ClassModel.Classs.IsActive;
                    Class.ClassName = ClassModel.Classs.ClassName;

                    return(Json(_classService.Update(Class).HttpGetResponse()));
                }
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
        }
        public IActionResult Edit(int id, ClasssViewModel model)
        {
            var getClasss = _ClasssService.GetClasssById(id);

            if (getClasss != null && getClasss.IsSucceeded)

            {
                getClasss.Result.ClassName = model.ClassName;

                var updateResult = _ClasssService.Update(getClasss.Result);

                if (updateResult.IsSucceeded)

                {
                    return(Ok(updateResult.Result));
                }
                return(updateResult.HttpGetResponse());
            }
            return(getClasss.HttpGetResponse());
        }