Ejemplo n.º 1
0
        public async Task <JsonResult> Save(ApplicationCore.Entities.SystemAggregate.Module entity)
        {
            JsonModel json = new JsonModel {
                Code = 200, Msg = "保存成功!"
            };

            try
            {
                //添加
                if (entity.Id <= 0)
                {
                    entity.CreateDate   = DateTime.Now;
                    entity.CreateUserId = Current.Id;
                    entity.UpdateDate   = DateTime.Now;
                    entity.UpdateUserId = Current.Id;
                    entity.IsShow       = true;

                    await _moduleService.CreateAsync(entity);
                }
                //修改
                else
                {
                    entity.UpdateDate   = DateTime.Now;
                    entity.UpdateUserId = Current.Id;

                    await _moduleService.UpdateAsync(entity);
                }
            }
            catch (Exception ex)
            {
                json.Code = 500;
                json.Msg  = $"保存异常!{ex.Message}";

                return(Json(json));
            }

            return(Json(json));
        }