public async Task <CarBrandModel> UpdateAsync(CarBrandModel model) { var entity = MapFromModel(model); var result = await _carBrandRepository.UpdateAsync(entity); return(MapToModel <CarBrandModel>(result)); }
public async Task <bool> AddBrand([FromBody] CarBrandModel brand) { var result = await _carContract.AddBrand(_mapper.Map <CarBrandModel, CarBrandPOCO>(brand)); if (result) { return(true); } return(false); }
public async Task <CarBrandModel> Put(int id, [FromBody] CarBrandModel model) { var result = await _carBrandService.UpdateAsync(model); return(result); }
public async Task <CarBrandModel> Post([FromBody] CarBrandModel model) { var result = await _carBrandService.AddAsync(model); return(result); }
/// <summary> /// 得到车子品牌信息 /// </summary> /// <param name="CarBrandCode"></param> /// <param name="Count"></param> /// <returns></returns> public List <CarBrandModel> GetCarBrand(int?CarBrandCode, out int Count) { List <CarBrandModel> olist = new List <CarBrandModel>(); Count = 0; SqlConnection sqlConnection = new SqlConnection(Config.ConnectionString); SqlCommand sqlcommand = new SqlCommand("sp_Province_City_Car", sqlConnection); sqlcommand.CommandType = CommandType.StoredProcedure; SqlParameter _op = new SqlParameter("@op", "GetBrand"); _op.Direction = ParameterDirection.Input; sqlcommand.Parameters.Add(_op); SqlParameter _ItemId = new SqlParameter("@ItemId", CarBrandCode == null ? (Object)DBNull.Value : CarBrandCode.Value); _ItemId.Direction = ParameterDirection.Input; sqlcommand.Parameters.Add(_ItemId); SqlParameter _result = new SqlParameter("@result", SqlDbType.Int); _result.Direction = ParameterDirection.Output; sqlcommand.Parameters.Add(_result); try { sqlConnection.Open(); using (IDataReader idr = sqlcommand.ExecuteReader()) { while (idr.Read()) { CarBrandModel oCModel = new CarBrandModel(); if (idr["CarBrandCode"] != DBNull.Value) { oCModel.CarBrandCode = (int)idr["CarBrandCode"]; } if (idr["CarBrandName"] != DBNull.Value) { oCModel.CarBrandName = (string)idr["CarBrandName"]; } if (idr["Firstletter"] != DBNull.Value) { oCModel.Firstletter = (string)idr["Firstletter"]; } if (idr["CreateTime"] != DBNull.Value) { oCModel.CreateTime = (DateTime)idr["CreateTime"]; } olist.Add(oCModel); } } Count = int.Parse(_result.Value.ToString()); } catch (Exception ex) { throw ex; } finally { sqlConnection.Close(); } return(olist); }