protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public IHttpActionResult PostOrder(Order order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var jobDetail = db.JobDetails.Find(order.JobDetailId); order.JobDetail = jobDetail; db.Orders.Add(order); db.SaveChanges(); db.Dispose(); db = new MoveMeDataContext(); order = db.Orders.Find(order.OrderId); TwilioClient.Init(Username, Password); var messageToMover = MessageResource.Create( to: new Twilio.Types.PhoneNumber(order.Company.Telephone), from: new Twilio.Types.PhoneNumber("+16193134173"), body: $"New job request" + Environment.NewLine + $"Job Date: {order?.JobDetail?.MovingDay}" + Environment.NewLine + $"Amount: ${order?.Cost}" + Environment.NewLine + Environment.NewLine + $"Reply CONFIRM {order?.OrderId} to accept job" + Environment.NewLine + $"Reply CANCEL {order?.OrderId} to cancel job" ); return(CreatedAtRoute("DefaultApi", new { id = order.OrderId }, new { order.OrderId, order.CustomerId, order.CompanyId, order.PaymentDetailId, order.Rating, order.Cost, order.Canceled, order.JobDetailId })); }