public async Task<IHttpActionResult> PostOrder(OrderInsert order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } Order newO = new Order() { FirstName = order.FirstName, LastName = order.LastName, StartTime = order.StartTime, EndTime = order.EndTime, Phone = order.Phone, SalonID = order.SalonID, Sex = order.Sex, UserName = order.UserName, OrderDetails = order.Services, CreateOn = DateTime.Now, Date = order.Date }; db.Orders.Add(newO); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = newO.OrderID }, newO); }
public async Task<IHttpActionResult> PostOrders(OrderInsert order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } DateTime iKnowThisIsUtc = order.Date; DateTime runtimeKnowsThisIsUtc = DateTime.SpecifyKind( iKnowThisIsUtc, DateTimeKind.Utc); var localVersion = TimeZoneInfo.ConvertTimeFromUtc(runtimeKnowsThisIsUtc, TimeZoneInfo.FindSystemTimeZoneById("FLE Standard Time"));//offset.ToOffset(new TimeSpan(3, 0, 0)); Order newO = new Order() { FirstName = order.FirstName, LastName = order.LastName, StartTime = order.StartTime, EndTime = order.EndTime, Phone = order.Phone, SalonID = order.SalonID, Sex = order.Sex, UserName = order.UserName, OrderDetails = order.Services, CreateOn = getTime, Date = localVersion, StartDateTime = localVersion.Add(order.StartTime), EndDateTime = localVersion.Add(order.EndTime), MoreInfo = order.MoreInfo, UniqueID = Guid.NewGuid(), }; db.Orders.Add(newO); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = newO.OrderID }, newO); }