示例#1
0
        public async Task <ActionResult> Edit(PartnerModel model)
        {
            var result = new JsonModel();

            if (!ModelState.IsValid)
            {
                result.GetError(ModelState);
                return(Json(result));
            }

            Partner partner       = null;
            var     operationType = OperationType.Update;

            if (model.Id > 0)
            {
                operationType = OperationType.Update;
                partner       = await PartnerRepository.GetEnableByIdAsync(model.Id);

                if (partner == null)
                {
                    result.statusCode = 300;
                    result.message    = "该条数据不存在,请刷新重试!";
                    return(Json(result));
                }
            }
            else
            {
                partner = new Partner();
            }
            Mapper.Map(model, partner);
            partner.CommonStatus = CommonStatus.Enabled;
            await PartnerRepository.SaveAsync(partner);

            await LogRepository.Insert(TableSource.Partner, operationType, "", partner.Id);

            result.Data    = partner;
            result.message = "保存成功!";
            return(Json(result));
        }