public ActionResult Create([Bind(Include = "Id,Name,Contact,Adress,PhoneNumber,Email")] Provider provider)
        {
            if (ModelState.IsValid)
            {
                db.Providers.Add(provider);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(provider));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "Id,Name,Contact,Position,Adress,PhoneNumber,Email,NDogovor,Description")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
        public ActionResult Create([Bind(Include = "Id,Category,Description")] Tip tip)
        {
            if (ModelState.IsValid)
            {
                db.Tips.Add(tip);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tip));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Position,BDay,Adress,Phone,Email")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
        public ActionResult Create([Bind(Include = "Id,Mark,Price,isAvailable,Measure,ProviderId,TipId")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProviderId = new SelectList(db.Providers, "Id", "Name", product.ProviderId);
            ViewBag.TipId      = new SelectList(db.Tips, "Id", "Category", product.TipId);
            return(View(product));
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                User user = null;
                using (SkladContext db = new SkladContext())
                {
                    user = db.Users.FirstOrDefault(u => u.Login == model.Login);
                }
                if (user == null)
                {
                    using (SkladContext db = new SkladContext())
                    {
                        db.Users.Add(new User {
                            Login = model.Login, Password = model.Password, Role = "manager"
                        });
                        db.SaveChanges();

                        user = db.Users.FirstOrDefault(u => u.Login == model.Login && u.Password == model.Password);
                    }
                    if (user != null)
                    {
                        //FormsAuthentication.SetAuthCookie(model.Login, true);
                        return(RedirectToAction("Users", "Admin"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Пользователь с таким логином или почтой уже существует");
                }
            }

            return(View(model));
        }
        public ActionResult EditClaim(Claim model)
        {
            Claim c1 = db.Claims.Include(c => c.Stock).FirstOrDefault(c => c.Id == model.Id);

            c1.Status      = model.Status;
            c1.CommentProd = model.CommentProd;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #8
0
        //To do возврат остатка на реализацию
        public void SaleDelete(int?id)
        {
            Sale sale = _db.Sales
                        .Include(s => s.Stock)
                        .FirstOrDefault(s => s.Id == id);

            var saleFirst = _db.Sales.Where(s => s.Number == sale.Number).OrderBy(s => s.Id).First();

            if (sale.Id == saleFirst.Id)
            {
                var sales = _db.Sales.Where(s => s.Number == sale.Number).OrderByDescending(s => s.Date).ToList();
                foreach (var s in sales)
                {
                    SaleDelete(s);
                }
            }
            else if (sale.Id != saleFirst.Id)
            {
                SaleDelete(sale);
            }

            _db.SaveChanges();
        }
Exemple #9
0
        public ActionResult UserNew(int?id, string login, string password, string role, string stock)
        {
            User user = _db.Users.FirstOrDefault(u => u.Id == id);

            user.Login    = login;
            user.Password = password;
            user.Role     = role;
            Stock s1 = null;

            s1 = _db.Stocks.FirstOrDefault(s => s.Name == stock);
            if (s1 != null)
            {
                user.Stock = s1;
            }
            _db.SaveChanges();

            return(RedirectToAction("Users", "Admin"));
        }