예제 #1
0
        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();
        }
예제 #2
0
 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();
 }
예제 #3
0
  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();
  }