public async Task <IActionResult> GetSize(int id) { Size size = await _repo.GetSize(id); if (size == null) { return(NotFound()); } return(Ok(size)); }
public IHttpActionResult PostLot(LotBindingModel model) { string fileName = Path.GetFileNameWithoutExtension(model.ImageFile.FileName); string extension = Path.GetExtension(model.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssffff") + extension; model.ImageFile.SaveAs(fileName); if (ModelState.IsValid) { var lot = new Lot { ImagePath = "~/Images/" + fileName, Noun = _nounRepo.GetNoun(model.NownName), Gender = _genderRepo.GetGender(model.GenderName), Size = _sizeRepo.GetSize(model.SizeValue), State = _stateRepo.GetState(model.StateName), Comment = model.Comment }; foreach (var item in model.ColorList) { lot.LotColors.Add(new LotColor { Color = _colorRepo.GetColor(item) }); } foreach (var item in model.StructureList) { lot.LotStructures.Add(new LotStructure { Structure = _structureRepo.GetStructure(item) }); } return(CreatedAtRoute("DefaultApi", new { id = lot.Id }, lot)); } else { return(BadRequest(ModelState)); } }