public IHttpActionResult PutLeague(int id, League league) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != league.LeagueId) { return(BadRequest()); } db.Entry(league).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LeagueExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult add_project(Projects p) { d.projects.Add(p); d.SaveChanges(); return(RedirectToAction("Projects")); }
public void Post([FromBody] Category prod) { var categories = _context.CategoryTable; prod.Category_id = categories.Max(x => x.Category_id) + 1; categories.Add(prod); _context.SaveChanges(); }
public void Post([FromBody] Master mast) { var masters = _context.MasterTable; mast.Master_id = masters.Max(x => x.Master_id) + 1; masters.Add(mast); _context.SaveChanges(); }
public void Post([FromBody] Customer cust) { var customers = _context.CustomerTable; cust.Customer_id = customers.Max(x => x.Customer_id) + 1; customers.Add(cust); _context.SaveChanges(); }
public void Post([FromBody] Detail det) { var details = _context.DetailTable; det.Detail_id = details.Max(x => x.Detail_id) + 1; details.Add(det); _context.SaveChanges(); }
public void Post([FromBody] Product prod) { var products = _context.ProductTable; prod.Product_id = products.Max(x => x.Product_id) + 1; products.Add(prod); _context.SaveChanges(); }
private static void AddInitialData(DateContext context) { if (!context.DateComparisonObjects.Any()) { context.DateComparisonObjects.AddRange(new List <DateComparisonObject> { new DateComparisonObject(DateTime.UtcNow.EndOfDay().Ticks, DateTime.UtcNow.EndOfDay().AddDays(1).Ticks), new DateComparisonObject(DateTime.UtcNow.EndOfDay().Ticks, DateTime.UtcNow.EndOfDay().AddDays(10).Ticks) }); } context.SaveChanges(); }
public IHttpActionResult PostInterval([FromBody] Interval interval) { if (ModelState.IsValid) { using (DateContext db = new DateContext()) { db.Intervals.Add(interval); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = interval.Id }, interval)); } } return(BadRequest(ModelState)); }
public IActionResult Add(String firstDate, String secondDate) { try { var mappedFirstDate = _dateMapper.MapDate(firstDate); var mappedSecondDate = _dateMapper.MapDate(secondDate); if (mappedFirstDate > mappedSecondDate) { return(Ok(Array.Empty <DateComparisonObjectDto>())); } _context.DateComparisonObjects.Add( new DateComparisonObject(mappedFirstDate, mappedSecondDate)); _context.SaveChanges(); } catch (ArgumentException) { return(BadRequest()); } catch (NotSupportedException) { return(BadRequest()); } return(Ok()); }