public IHttpActionResult PutJobDetail(int id, JobDetail jobDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != jobDetail.JobDetailId) { return(BadRequest()); } var dbJobDetail = db.JobDetails.Find(id); dbJobDetail.JobDetailId = jobDetail.JobDetailId; dbJobDetail.CustomerId = jobDetail.CustomerId; dbJobDetail.FromStreetAddress = jobDetail.FromStreetAddress; dbJobDetail.FromCity = jobDetail.FromCity; dbJobDetail.FromState = jobDetail.FromState; dbJobDetail.FromZip = jobDetail.FromZip; dbJobDetail.ToStreetAddress = jobDetail.ToStreetAddress; dbJobDetail.ToCity = jobDetail.ToCity; dbJobDetail.ToState = jobDetail.ToState; dbJobDetail.ToZip = jobDetail.ToZip; dbJobDetail.MovingDay = jobDetail.MovingDay; dbJobDetail.NumBedroom = jobDetail.NumBedroom; dbJobDetail.NumPooper = jobDetail.NumPooper; dbJobDetail.SqFeet = jobDetail.SqFeet; dbJobDetail.Stairs = jobDetail.Stairs; dbJobDetail.Elevator = jobDetail.Elevator; dbJobDetail.NumMovers = jobDetail.NumMovers; dbJobDetail.NumHours = jobDetail.NumHours; dbJobDetail.Distance = jobDetail.Distance; db.Entry(dbJobDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!JobDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCompany(int id, Company company) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != company.CompanyId) { return(BadRequest()); } var dbCompany = db.Companys.Find(id); dbCompany.CompanyId = company.CompanyId; dbCompany.CompanyName = company.CompanyName; dbCompany.Telephone = company.Telephone; dbCompany.StreetAddress = company.StreetAddress; dbCompany.City = company.City; dbCompany.State = company.State; dbCompany.Zip = company.Zip; dbCompany.Employees = company.Employees; dbCompany.Radius = company.Radius; dbCompany.HourlyRate = company.HourlyRate; db.Entry(dbCompany).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutOrder(int id, Order order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != order.OrderId) { return(BadRequest()); } var dbOrder = db.Orders.Find(id); dbOrder.OrderId = order.OrderId; dbOrder.CustomerId = order.CustomerId; dbOrder.CompanyId = order.CompanyId; dbOrder.PaymentDetailId = order.PaymentDetailId; dbOrder.Rating = order.Rating; dbOrder.Cost = order.Cost; dbOrder.Canceled = order.Canceled; dbOrder.JobDetail = order.JobDetail; db.Entry(dbOrder).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutPaymentDetail(int id, PaymentDetail paymentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != paymentDetail.PaymentDetailId) { return(BadRequest()); } var dbPaymentDetail = db.PaymentDetails.Find(id); dbPaymentDetail.PaymentDetailId = paymentDetail.PaymentDetailId; dbPaymentDetail.CustomerId = paymentDetail.CustomerId; dbPaymentDetail.CCNumber = paymentDetail.CCNumber; dbPaymentDetail.ExpDate = paymentDetail.ExpDate; dbPaymentDetail.CCV = paymentDetail.CCV; dbPaymentDetail.StreetAddress = paymentDetail.StreetAddress; dbPaymentDetail.City = paymentDetail.City; dbPaymentDetail.State = paymentDetail.State; dbPaymentDetail.Zip = paymentDetail.Zip; db.Entry(dbPaymentDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaymentDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCustomer(int id, Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.CustomerId) { return(BadRequest()); } var dbCustomer = db.Customers.Find(id); dbCustomer.CustomerId = customer.CustomerId; dbCustomer.FirstName = customer.FirstName; dbCustomer.LastName = customer.LastName; dbCustomer.Telephone = customer.Telephone; db.Entry(dbCustomer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutUser(int id, User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.UserId) { return(BadRequest()); } var dbUser = db.Users.Find(id); dbUser.UserId = user.UserId; dbUser.EmailAddress = user.EmailAddress; dbUser.Password = user.Password; dbUser.Company = user.Company; dbUser.Customer = user.Customer; db.Entry(dbUser).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult ReceiveText(SmsRequest request) { TwilioClient.Init(Username, Password); try { var orderId = int.Parse(request.Body.Split(' ')[1]); var order = db.Orders.Find(orderId); if (request.Body.Contains("CONFIRM")) { order.Confirmed = true; db.Entry(order).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var message = MessageResource.Create( to: new Twilio.Types.PhoneNumber(order.Company.Telephone), from: new Twilio.Types.PhoneNumber("+16193134173"), body: "Ok, cool! We've confirmed that you're taking this job." ); var messageToCustomer = MessageResource.Create( to: new Twilio.Types.PhoneNumber(order.Customer.Telephone), from: new Twilio.Types.PhoneNumber("+16193134173"), body: $"Hello {order.Customer.FirstName}{order.Customer.LastName}, your moving date on {order?.JobDetail?.MovingDay} has been confirmed!" + Environment.NewLine + $"Please reply DONE {orderId} when job is completed" ); } else if (request.Body.Contains("DONE")) { order.Completed = true; db.Entry(order).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var message = MessageResource.Create( to: new Twilio.Types.PhoneNumber(order.Company.Telephone), from: new Twilio.Types.PhoneNumber("+16193134173"), body: "Customer confirmed job completion." ); } else if (request.Body.Contains("CANCEL")) { order.Canceled = true; db.Entry(order).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); var message = MessageResource.Create( to: new Twilio.Types.PhoneNumber(order.Customer.Telephone), from: new Twilio.Types.PhoneNumber("+16193134173"), body: "Company is unable to do the yob requested, please visit our website to schedule a new order" ); } return(Ok()); } catch (Exception) { var message = MessageResource.Create( to: new Twilio.Types.PhoneNumber(request.From), from: new Twilio.Types.PhoneNumber("+16193134173"), body: "Sorry, I couldn't understand your message." ); return(Ok()); } }