Ejemplo n.º 1
0
 public void Edit(OrderModel order)
 {
     var orderToEdit = context.Orders.Find(order.Id);
     //orderToEdit = SaveEditedOrder(order, orderToEdit);
     context.SaveChanges();
 }
Ejemplo n.º 2
0
        public Book SaveEditedOrder(OrderModel model, Order order)
        {
            //book.Id = model.Id;
            //book.Authors = ConvertModelAuthorToDBAuthor(model.Id);
            //book.Publisher = GetPublisherByName(model.Publisher.Name);
            //book.Genres = ConvertModelGenreToDBGenre(model.Id);
            //if (model.Readers != null)
            //{
            //	book.Readers = ConvertModelReaderToDBReader(model.Id);
            //}
            //book.Format = GetFormatByName(model.Format.Name);
            //book.Language = GetLanguageByName(model.Language.Name);
            //if (model.Series != null)
            //{
            //	book.Series = GetSeriesByName(model.Series.Name);
            //}
            //book.Title = model.Title;
            //book.Description = model.Description;
            //book.ImagePath = model.ImagePath;
            //book.ISBN = model.ISBN;
            //book.PageNumber = model.PageNumber;
            //book.Price = model.Price;
            //book.PublishingDate = model.PublishingDate;
            //book.QuantityInStock = model.QuantityInStock;
            //book.Weight = model.Weight;

            return null;
        }
Ejemplo n.º 3
0
        public ActionResult Edit(OrderModel model)
        {
            var currentUser = _userRepository.GetByUsername(User.Identity.Name);
            var order = _ordersRepository.GetById(model.Id);
            if (order.User.Id != currentUser.Id)
                throw new Exception("Access to invalid object");
            var category = _categoryRepository.GetById(model.Category);
            if (category == null)
                throw new Exception("Category is null");
            var subCategory = _subcategoryRepository.GetById(model.Subcategory);
            double price;
            double.TryParse(model.Price.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture,
                out price);

            order.Title = model.Title;
            order.Category = category;
            order.SubCategory = subCategory;
            order.Description = model.Description;
            order.Price = price;
            order.Images = model.Images;
            order.RelatedUrl = model.RelatedUrl;
            order.ResponseTime = model.ResponseTime;
            order.BidLimit = model.BidLimit;
            order.EnableFollowersLimitation = model.EnableFollowersLimitation == "on";
            order.FollowersLimitation = model.FollowersLimitation;

            _ordersRepository.Update(order);

            return RedirectToAction("MyOrders");
        }
Ejemplo n.º 4
0
		public async Task<ActionResult> DeleteOrder(int id, OrderModel model)
		{
			try
			{
				await apiModelOrder.DeleteOrder("api/APIDbOrder/", id.ToString(), model);

				return RedirectToAction("Index");
			}
			catch
			{
				return View();
			}
		}
Ejemplo n.º 5
0
 public ActionResult Create(OrderModel model)
 {
     if (string.IsNullOrEmpty(model.Title) || string.IsNullOrEmpty(model.Description))
         throw new Exception("Validation error");
     var user = _userRepository.GetByUsername(User.Identity.Name);
     var category = _categoryRepository.GetById(model.Category);
     if (category == null)
         throw new Exception("Category is null");
     var subCategory = _subcategoryRepository.GetById(model.Subcategory);
     double price;
     double.TryParse(model.Price.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture,
         out price);
     var order = new Order
     {
         Title = model.Title,
         Description = model.Description,
         User = user,
         Category = category,
         SubCategory = subCategory,
         CreateDate = DateTime.Now,
         IsDeleted = false,
         ResponseTime = model.ResponseTime,
         RelatedUrl = model.RelatedUrl,
         Images = model.Images,
         BidLimit = model.BidLimit,
         Price = price,
         EnableFollowersLimitation = model.EnableFollowersLimitation == "on",
         FollowersLimitation = model.FollowersLimitation
     };
     _ordersRepository.Add(order);
     return RedirectToAction("MyOrders");
 }