Ejemplo n.º 1
0
        /// <summary>
        /// 新增或者修改服务
        /// </summary>
        /// <param name="item">新增或者修改试图实体</param>
        /// <returns>结果实体</returns>
        public async Task <BaseResult> AddOrModifyAsync(ManagerRoleAddOrModifyModel item)
        {
            var         result = new BaseResult();
            ManagerRole managerRole;

            if (item.Id == 0)
            {
                //TODO ADD
                managerRole = _mapper.Map <ManagerRole>(item);
                managerRole.AddManagerId = 1;
                managerRole.IsDelete     = false;
                managerRole.AddTime      = DateTime.Now;
                if (await _repository.InsertByTransAsync(managerRole) > 0)
                {
                    result.ResultCode = ResultCodeAddMsgKeys.CommonObjectSuccessCode;
                    result.ResultMsg  = ResultCodeAddMsgKeys.CommonObjectSuccessMsg;
                }
                else
                {
                    result.ResultCode = ResultCodeAddMsgKeys.CommonExceptionCode;
                    result.ResultMsg  = ResultCodeAddMsgKeys.CommonExceptionMsg;
                }
            }
            else
            {
                //TODO Modify
                managerRole = await _repository.GetAsync(item.Id);

                if (managerRole != null)
                {
                    _mapper.Map(item, managerRole);
                    managerRole.ModifyManagerId = 1;
                    managerRole.ModifyTime      = DateTime.Now;
                    if (await _repository.UpdateByTransAsync(managerRole) > 0)
                    {
                        result.ResultCode = ResultCodeAddMsgKeys.CommonObjectSuccessCode;
                        result.ResultMsg  = ResultCodeAddMsgKeys.CommonObjectSuccessMsg;
                    }
                    else
                    {
                        result.ResultCode = ResultCodeAddMsgKeys.CommonExceptionCode;
                        result.ResultMsg  = ResultCodeAddMsgKeys.CommonExceptionMsg;
                    }
                }
                else
                {
                    result.ResultCode = ResultCodeAddMsgKeys.CommonFailNoDataCode;
                    result.ResultMsg  = ResultCodeAddMsgKeys.CommonFailNoDataMsg;
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public string AddOrModify([FromForm] ManagerRoleAddOrModifyModel item)
        {
            var result = new BaseResult();
            ManagerRoleValidation validationRules = new ManagerRoleValidation();
            ValidationResult      results         = validationRules.Validate(item);

            if (results.IsValid)
            {
                result = _service.AddOrModify(item);
            }
            else
            {
                result.ResultCode = ResultCodeAddMsgKeys.CommonModelStateInvalidCode;
                result.ResultMsg  = results.ToString("||");
            }
            return(JsonHelper.ObjectToJSON(result));
        }
Ejemplo n.º 3
0
 public BaseResult AddOrModify(ManagerRoleAddOrModifyModel item)
 {
     throw new NotImplementedException();
 }