protected void ButtonAddBicycleData_Click(object sender, EventArgs e) { string filePathJson = HttpContext.Current.Server.MapPath("~/Common/DataToImport/BicyclesData.json"); var loadBicycles = new LoadBicycleData(); var bicycles = loadBicycles.LoadDataFromJson(filePathJson); var bicyclesFactory = new CreateBicycle(); bicyclesFactory.CreateMany(bicycles); }
public async Task <IActionResult> Post([FromBody] CreateBicycle createBicycle) { var bicycle = new Bicycle { UserId = createBicycle.UserId, ProductionDate = createBicycle.ProductionDate, Type = createBicycle.Type }; await _context.AddAsync(bicycle); await _context.SaveChangesAsync(); return(Created(bicycle.BicycleId.ToString(), new BicycleViewModel { UserId = bicycle.UserId, ProductionDate = bicycle.ProductionDate, Type = bicycle.Type })); }