public IActionResult CompareMessage(Message message)
 {
     db.Messages.Add(message);
     db.SaveChanges();
     ViewBag.String = "Сообщение отправлено.";
     return(View());
 }
示例#2
0
        public void CreateOrder(Order order)
        {
            order.OrderTime = DateTime.Now;
            _appDbContent.Orders.Add(order);

            _appDbContent.SaveChanges();
            var items = _shopCart.ListShopItems;

            foreach (var el in items)
            {
                var orderDetail = new OrderDetail()
                {
                    SneakerId   = el.Sneaker.Id,
                    OrderId     = order.Id,
                    Price       = el.Sneaker.Price,
                    Adress      = order.Adress,
                    Name        = order.Name,
                    Phone       = order.Phone,
                    SneakerName = el.Sneaker.Name,
                    Surname     = order.Surname,
                    SneakerSize = order.SneakerSizeOrder
                };
                _appDbContent.OrderDetail.Add(orderDetail);
            }
            _appDbContent.SaveChanges();
        }
示例#3
0
 public ActionResult Create(Contract contract)
 {
     if (HttpContext.Session.GetString("actions") == "admin")
     {
         try
         {
             using (appDBContent)
             {
                 appDBContent.Contract.Add(contract);
                 appDBContent.SaveChanges();
             }
             return(RedirectToAction("Index"));
         }
         catch
         {
             ViewBag.Message = "Данные некорректны!";
             return(View());
             //return RedirectToAction("Index");
         }
     }
     else
     {
         return(RedirectToRoute(new { controller = "Employee", action = "Login" }));
     }
 }
 public ActionResult Create(DepositType depositType)
 {
     if (HttpContext.Session.GetString("actions") == "admin")
     {
         try
         {
             using (appDBContent)
             {
                 if (depositType.capitalization > 0 && depositType.minMoney > 0 && depositType.percent > 0 && depositType.percent < 100 && depositType.period > 0 && depositType.maxMoney > depositType.minMoney)
                 {
                     appDBContent.DepositType.Add(depositType);
                     appDBContent.SaveChanges();
                 }
                 else
                 {
                     ViewBag.Message = "Данные некорректны!";
                     return(View());
                 }
             }
             return(RedirectToAction("Index"));
         }
         catch
         {
             return(View());
             //return RedirectToAction("Index");
         }
     }
     else
     {
         return(RedirectToRoute(new { controller = "Employee", action = "Login" }));
     }
 }
示例#5
0
        public void createOrder(Order order)
        {
            order.orderTime = DateTime.Now;
            appDBContent.Order.Add(new Order
            {
                orderName    = order.orderName,
                orderAddress = order.orderAddress,
                orderPhone   = order.orderPhone,
                email        = order.email,
                orderTime    = order.orderTime
            });
            appDBContent.SaveChanges();

            var          items     = shopCart.listShopItems;
            List <Order> currOrder = appDBContent.Order.Where(t => t.orderTime == order.orderTime).OrderBy(t => t.orderId).ToList();

            foreach (var el in items)
            {
                appDBContent.OrderDetail.Add(new OrderDetail
                {
                    orderId = currOrder[0].orderId,
                    carId   = el.car.carId,
                    price   = el.car.carPrice
                });
            }
            appDBContent.SaveChanges();
        }
示例#6
0
        public dynamic GetCart(IServiceProvider services)
        {
            ISession session = services.GetRequiredService <IHttpContextAccessor>()?.HttpContext.Session;
            string   _cartId = session.GetString("cartId") ?? Guid.NewGuid().ToString();

            session.SetString("cartId", _cartId);
            Cart cart = new Cart(_cartId);

            if (String.IsNullOrEmpty(session.GetString("profileId")))
            {
                appDBContent.Carts.Add(cart);
            }
            else
            {
                cart.ProfileId = session.GetString("profileId");
                appDBContent.Carts.Add(cart);
            }
            try
            {
                appDBContent.SaveChanges();
            }
            catch (Exception e)
            {
                return(null);
            }
            return(cart);
        }
示例#7
0
        public ActionResult Create(Client client)
        {
            if (HttpContext.Session.GetString("actions") == "admin")
            {
                try
                {
                    using (appDBContent)
                    {
                        List <Client> cl = new List <Client>();

                        cl = appDBContent.Client.Where(x => x.passport == client.passport).ToList();
                        if (cl.Count == 0)
                        {
                            appDBContent.Client.Add(client);
                            appDBContent.SaveChanges();
                        }
                        else
                        {
                            ViewBag.Message = "Клиент уже зарегистрирован в системе!";
                            return(View());
                        }
                    }
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                    //return RedirectToAction("Index");
                }
            }
            else
            {
                return(RedirectToRoute(new { controller = "Employee", action = "Login" }));
            }
        }
        public ActionResult Create(Employee emp)
        {
            if (HttpContext.Session.GetString("actions") == "admin")
            {
                try
                {
                    using (appDBContent)
                    {
                        List <Employee> empl = new List <Employee>();

                        empl = appDBContent.Employee.Where(x => x.EmployeeLogin == emp.EmployeeLogin).ToList();
                        if (empl.Count == 0)
                        {
                            appDBContent.Employee.Add(emp);
                            appDBContent.SaveChanges();
                        }
                        else
                        {
                            ViewBag.Message = "Сотрудник уже зарегистрирован в системе!";
                            return(View());
                        }
                    }
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                    //return RedirectToAction("Index");
                }
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
示例#9
0
        public void AddToRoster(Unit unit)
        {
            this.appDBContent.RosterItem.Add(new RosterItem {
                rosterId = rosterId, unit = unit
            });

            appDBContent.SaveChanges();
        }
示例#10
0
        public void Remove(Service Service)
        {
            var item = _AppDBContent.Service.Where(x => x.ServiceId == Service.ServiceId).FirstOrDefault();

            _AppDBContent.Service.Remove(item);

            _AppDBContent.SaveChanges();
        }
        public void CreateSubscription(Subscription Subscription)
        {
            Subscription.StartSubscription = DateTime.Now.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);

            appDbContent.Subscription.Add(Subscription);

            appDbContent.SaveChanges();
        }
示例#12
0
        public IActionResult Execution(int Id)
        {
            var order = _appDBContent.Orders
                        .FirstOrDefault(o => o.Id == Id);

            order.Status = "На исполнении";
            _appDBContent.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#13
0
 public void AddToCart(Shoes shoes)
 {
     appDBContent.ShopCartItem.Add(new ShopCartItem {
         ShopCartId = ShopCartId,
         shoes      = shoes,
         price      = shoes.price
     });
     appDBContent.SaveChanges();
 }
示例#14
0
 public void AddAuthor(string nameAuthor)
 {
     appDBContent.Authors.Add(new Author
     {
         NameAuthor           = nameAuthor,
         NormalizedNameAuthor = nameAuthor.ToUpper()
     });
     appDBContent.SaveChanges();
 }
示例#15
0
文件: ShopCart.cs 项目: DieErste/web
 //добавление в корзину позиции
 //кол-во = 1 пока при первом добавлении оставил
 public void AddToCart(Item item)
 {
     _appDBContent.shopCartItem.Add(new ShopCartItem {
         shopCartID = shopCartID,
         item       = item,
         quantity   = 1,
         price      = item.price
     });
     _appDBContent.SaveChanges();
 }
示例#16
0
 public void AddToBasket(Book book)
 {
     _appDbContent.ShopBasketItem.Add(new ShopBasketItem
     {
         ShopBasketId = ShopBasketId,
         Book         = book,
         Price        = book.Price
     });
     _appDbContent.SaveChanges();
 }
示例#17
0
        public Auto GetAuto(int autoId) => appDBContent.Auto.FirstOrDefault(p => p.Id == autoId);    //Search by ID

        public string AddAuto(Auto element)                                                          //Add object to DB
        {
            if (Autos.Select(s => s.Number == element.Number).Select(c => c == true).Contains(true)) //Validate if the object has already been added
            {
                return("Объект уже существует");
            }
            appDBContent.Add(element);
            appDBContent.SaveChanges();
            return("Автомобиль добавлен");
        }
示例#18
0
 public bool Insert(Category category)
 {
     // проверка имени чтобы не совпадало
     if (_appDBContent.category.FirstOrDefault(c => string.Equals(c.name, category.name, StringComparison.OrdinalIgnoreCase)) != null)
     {
         return(false);
     }
     _appDBContent.category.Add(category);
     _appDBContent.SaveChanges();
     return(true);
 }
示例#19
0
        public void AddToCart(Toy toy)
        {
            AppDBContent.ToyShopCartItem.Add(new ToyShopCartItem
            {
                ToyShopCartId = ToyShopCartId,
                toy           = toy,
                price         = toy.Price
            });

            AppDBContent.SaveChanges();
        }
示例#20
0
        public void AddToCart(Car car)
        {
            appDBContent.ShopCartItem.Add(new ShopCartItem
            {
                ShopCartId = ShopCartId,
                car        = car,
                price      = car.price
            });

            appDBContent.SaveChanges();
        }
示例#21
0
        public void AddToCart(GardeningItem item)
        {
            appDBContent.ShopCartItem.Add(new ShopCartItem
            {
                ShopCartId = ShopCartId,
                Item       = item,
                Price      = item.Price
            });

            appDBContent.SaveChanges();
        }
示例#22
0
        public void AddToCart(Course course)
        {
            appDBContent.ShopCourseItems.Add(new ShopCartItem
            {
                ShopCartId = this.ShopCartId,
                Course     = course,
                Price      = course.Price
            });

            appDBContent.SaveChanges();
        }
示例#23
0
        public void AddToSite(Site site)
        {
            appDBContent.ShopSitesItem.Add(new ShopSitesItem
            {
                ShopSitesId = ShopSiteId,
                site        = site,
                price       = site.price
            });

            appDBContent.SaveChanges();
        }
示例#24
0
 public bool Insert(Item item)
 {
     // проверка не повторения имени
     if (_appDBContent.item.FirstOrDefault(i => string.Equals(i.name, item.name, StringComparison.OrdinalIgnoreCase)) != null)
     {
         return(false);
     }
     _appDBContent.item.Add(item);
     _appDBContent.SaveChanges();
     return(true);
 }
示例#25
0
 public void AddMatch(MatchAdd matchToAdd, Match newMatch, MatchParticipant MP1, MatchParticipant MP2)
 {
     appDBContent.Matches.Add(newMatch);
     appDBContent.SaveChanges();
     appDBContent.MatchParticipant.Add(new MatchParticipant {
         player = Convert.ToString(matchToAdd.win), matchID = Convert.ToInt32(newMatch.Id), result = 1
     });
     appDBContent.MatchParticipant.Add(new MatchParticipant {
         player = Convert.ToString(matchToAdd.lose), matchID = Convert.ToInt32(newMatch.Id), result = 0
     });
     appDBContent.SaveChanges();
 }
示例#26
0
        public ActionResult CreateProduct(Product product, int categoryId, IFormFile uploadedFile)
        {
            string path = $"/img/{DateTime.Now.ToString("yyyyMMddHHmmss")}.jpg";

            using (var fileStream = new FileStream(_environment.WebRootPath + path, FileMode.CreateNew))
            {
                uploadedFile.CopyTo(fileStream);
            }
            product.Category  = _categories.AllCategories.Where(x => x.Id == categoryId).FirstOrDefault();
            product.ImagePath = $"{path}";
            _content.Product.Add(product);
            _content.SaveChanges();
            return(RedirectToAction("List"));
        }
        public void AddBook(string id, Book book)
        {
            LibraryToRead library = appDBContent.Libraries.FirstOrDefault(l => l.Guid.Equals(id));

            if (library == null)
            {
                library = new LibraryToRead()
                {
                    Guid = id
                };
                appDBContent.Libraries.Add(library);
            }
            library.AddBook(book);
            appDBContent.SaveChanges();
        }
示例#28
0
        //сохранить новую либо обновить существующую запись в БД
        public Guid SaveArticle(RegisteViewModel entity)
        {
            if (entity.id == default)
            {
                context.Entry(entity).State = EntityState.Added;
                context.RegisteViewModel.Add(entity);
            }
            else
            {
                context.Entry(entity).State = EntityState.Modified;
            }
            context.SaveChanges();

            return(entity.id);
        }
示例#29
0
        public void createOrder(Order order)
        {
            try {
                if (order != null)
                {
                    order.OrderTime = DateTime.Now;
                    AppDBContent.Order.Add(order);

                    var items = ShopCart.ListShopItems; //получаем все товары

                    foreach (var elem in items)
                    {
                        var orderDetail = new OrderDetail()
                        {
                            CarId   = elem.Car.Id,
                            OrderId = order.Id,
                            Price   = elem.Car.Price
                        };
                        AppDBContent.OrderDetail.Add(orderDetail);
                    }
                    AppDBContent.SaveChanges();
                }
            }
            catch (Exception e) {
                Console.WriteLine("Ошибка: " + e);
            }
        }
示例#30
0
        public async Task <IActionResult> AddFile(IFormFile uploadedFile)
        {
            var currentUserid = _iuser.AllUsers.First(i => i.Email == User.Identity.Name);

            if (uploadedFile != null)
            {
                string path = _appEnvironment.WebRootPath + $"/Files/{currentUserid.Email}/";
                Directory.CreateDirectory(path);

                // The path to the folder Files
                path += uploadedFile.FileName;
                // I save the file to a folder Files in the catalog wwwroot
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await uploadedFile.CopyToAsync(fileStream);
                }
                Files file = new Files {
                    Name = uploadedFile.FileName, Path = path, UserId = currentUserid.Id
                };
                _appDBContent.Files.Add(file);
                _appDBContent.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }