Пример #1
0
        private WebResponseContent Add <TDetail>(SaveModel saveDataModel) where TDetail : class
        {
            T mainEntity = saveDataModel.MainData.DicToEntity <T>();
            //验证明细
            string reslut = typeof(TDetail).ValidateDicInEntity(saveDataModel.DetailData, true, false, new string[] { TProperties.GetKeyName() });

            if (reslut != string.Empty)
            {
                return(Response.Error(reslut));
            }

            List <TDetail> list = saveDataModel.DetailData.DicToList <TDetail>();

            Response = Add <TDetail>(mainEntity, list, false);

            //保存失败
            if (!Response.Status)
            {
                Logger.Error(LoggerType.Add, saveDataModel.Serialize() + Response.Message);
                return(Response);
            }

            PropertyInfo propertyKey = typeof(T).GetKeyProperty();

            saveDataModel.MainData[propertyKey.Name] = propertyKey.GetValue(mainEntity);
            Response.Data = new { data = saveDataModel.MainData, list };
            return(Response.Set(ResponseType.SaveSuccess));
        }
Пример #2
0
        public virtual async Task <WebResponseContent> Update(SaveModel saveModel)
        {
            ResponseContent = await Task.Run(() => InvokeService("Update", new object[] { saveModel })) as WebResponseContent;

            Logger.Info(Enums.LoggerType.Edit, saveModel.Serialize(), ResponseContent.Status ? "Ok" : ResponseContent.Message);
            return(ResponseContent);
        }
 public virtual ActionResult Update([FromBody] SaveModel saveModel)
 {
     _baseWebResponseContent = InvokeService("Update", new object[] { saveModel }) as WebResponseContent;
     Logger.Info(Enums.LoggerType.Edit, saveModel.Serialize(), _baseWebResponseContent.Status ? "Ok" : _baseWebResponseContent.Message);
     _baseWebResponseContent.Data = _baseWebResponseContent.Data?.Serialize();
     return(Json(_baseWebResponseContent));
 }
Пример #4
0
        public virtual async Task <WebResponseContent> Add(SaveModel saveModel)
        {
            ResponseContent = await Task.FromResult(InvokeService("Add", new Type[] { typeof(SaveModel) }, new object[] { saveModel })) as WebResponseContent;

            Logger.Info(Enums.LoggerType.Add, saveModel.Serialize(), ResponseContent.Status ? "Ok" : ResponseContent.Message);
            return(ResponseContent);
        }