public async Task <IResultModel> Add(AreaAddModel model) { var entity = _mapper.Map <AreaEntity>(model); if (await _repository.Exists(entity)) { return(ResultModel.HasExists); } var result = await _repository.AddAsync(entity); return(ResultModel.Result(result)); }
public ActionResult AddAreaInfo(AreaAddModel model) { if (ModelState.IsValid) { var result = AreaBLL.AddAreaInfo(model, base.UserIDForLog); base.DoLog(OperationTypeEnum.Add, result, "AreaName:" + model.AreaName); return(Json(result)); } else { return(PartialView("_AddAreaInfo", model)); } }
public async Task <IResultModel> Add(AreaAddModel model) { var entity = _mapper.Map <AreaEntity>(model); if (await _repository.Exists(entity)) { return(ResultModel.HasExists); } entity.Pinyin = NPinyin.Pinyin.GetPinyin(entity.Name); entity.Jianpin = NPinyin.Pinyin.GetInitials(entity.Name); var result = await _repository.AddAsync(entity); return(ResultModel.Result(result)); }
/// <summary> /// 新增区域信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static OperationResult AddAreaInfo(AreaAddModel model, int UserID) { List <SqlParameter> paras = new List <SqlParameter>(); paras.Add(new SqlParameter() { ParameterName = "@areaName", SqlDbType = SqlDbType.NVarChar, Size = 20, Value = model.AreaName.Trim(), }); paras.Add(new SqlParameter("@description", SqlDbType.NVarChar, 50)); paras.Add(new SqlParameter("@CreateUserID", SqlDbType.Int)); if (string.IsNullOrWhiteSpace(model.Description)) { paras[1].Value = DBNull.Value; } else { paras[1].Value = model.Description; } paras[2].Value = UserID; string sql = @"INSERT INTO dbo.Areas ( AreaName, Description,CreateUserID ) VALUES ( @areaName,@description,@CreateUserID);"; bool result = MSSQLHelper.ExecuteNonQuery(CommandType.Text, sql, paras.ToArray()) > 0; return(new OperationResult() { Success = result, Message = result ? PromptInformation.OperationSuccess : PromptInformation.DBError }); }
public Task <IResultModel> Add(AreaAddModel model) { return(_service.Add(model)); }