public IHttpActionResult Post(int id, OrderBindingModel model) { model.CustomerUserName = User.Identity.Name; if (!ModelState.IsValid) { return BadRequest(ModelState); } _ordersService.UpdateOrder(id, model, User.Identity.Name); return Ok(); }
public void CreateOrder(OrderBindingModel model) { var order = new Order { Business = _businessRepo.FindByBusinessUserName(model.BusinessUserName), Customer = _customerRepo.FindByCustomerUserName(model.CustomerUserName), ServiceName = model.ServiceName, OrderDate = DateTime.Parse(model.OrderDate), CompletionDate = DateTime.Parse(model.CompletionDate), Price = model.Price, ServiceQuality = 0, IsApproved = false, IsCompleted = false }; _repo.Add(order); _repo.SaveChanges(); }
public void UpdateOrder(int id, OrderBindingModel model, string username) { Order order = _repo.FindById(id, username); if (order != null) { order.Customer = _customerRepo.FindByCustomerUserName(model.CustomerUserName); order.ServiceName = model.ServiceName; order.OrderDate = DateTime.Parse(model.OrderDate); order.CompletionDate = DateTime.Parse(model.CompletionDate); order.Price = model.Price; order.ServiceQuality = model.ServiceQuality; order.IsApproved = model.IsApproved; order.IsCompleted = model.IsCompleted; }; _repo.SaveChanges(); }