public async Task<IHttpActionResult> Create(ModelDto dto) { Model model = new Model { Available = true, Brand = dto.Brand, Id = dto.Id, Modeling = dto.Modeling, Price = dto.Price, Series = dto.Series }; if (await this.modelService.Exist(model)) { return this.BadRequest("车型信息已经存在"); } return this.Ok((await this.modelService.Create(model)).ToDto()); }
public async Task<IHttpActionResult> Exist(ModelDto dto) { Model model = new Model { Brand = dto.Brand, Modeling = dto.Modeling, Price = dto.Price, Series = dto.Series }; return this.Ok(new BoolResponse { Result = await this.modelService.Exist(model) }); }
public async Task<IHttpActionResult> Edit([FromUri] int id, ModelDto dto) { Model model = await this.modelService.Get(id, true); if (model == null) { return this.BadRequest("无此车型,请确认车型id是否正确"); } model.Brand = dto.Brand; model.Modeling = dto.Modeling; model.Price = dto.Price; model.Series = dto.Series; if (await this.modelService.Exist(model)) { return this.BadRequest("车型信息已经存在"); } return this.Ok((await this.modelService.Edit(id, model)).ToDto()); }