Пример #1
0
        public ActionResult Create(ViewBuyer vbuyer)
        {
            if (ModelState.IsValid)
            {
                BuyerAddress address = new BuyerAddress();
                address.Area  = areaRepo.Get(vbuyer.Area);
                address.City  = cityRepo.Get(vbuyer.City);
                address.Block = vbuyer.Block;
                address.House = vbuyer.House;
                address.Road  = vbuyer.House;

                BuyerLogin login = new BuyerLogin();
                login.Username = vbuyer.Username;
                login.Password = vbuyer.Password;

                BuyerApproval approval = new BuyerApproval();
                approval.Status = false;

                Buyer buyer = new Buyer();
                buyer.FirstName = vbuyer.FirstName;
                buyer.LastName  = vbuyer.LastName;
                buyer.Email     = vbuyer.Email;
                buyer.Phone     = vbuyer.Phone;
                buyer.Gender    = vbuyer.Gender;
                buyer.Address   = address;
                buyer.LoginData = login;
                buyer.Approval  = approval;

                buyerRepo.Insert(buyer);

                return(RedirectToAction("Index", "Home"));
            }

            return(View(vbuyer));
        }
Пример #2
0
        public ActionResult Index(int id)
        {
            Buyer         buyer    = buyerRepo.GetByLogin(id);
            BuyerApproval approval = approvalRepo.Get(buyer.ApprovalId);

            if (approval.Status)
            {
                Session["BID"] = buyer.BuyerId;

                if (InitCart() == 1)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                else
                {
                    return(View("Error"));
                }
            }

            else
            {
                return(View("Error"));
            }
        }
Пример #3
0
        public int UpdateApproval(int id, bool status)
        {
            BuyerApproval buyerApprovalToUpdate = context.BuyerApprovals.SingleOrDefault(a => a.Id == id);

            buyerApprovalToUpdate.Status = status;

            return(context.SaveChanges());
        }
Пример #4
0
        public int Delete(int id)
        {
            BuyerApproval buyerApprovalToDelete = context.BuyerApprovals.SingleOrDefault(a => a.Id == id);

            context.BuyerApprovals.Remove(buyerApprovalToDelete);

            return(context.SaveChanges());
        }
Пример #5
0
        public int Insert(BuyerApproval BuyerApproval)
        {
            context.BuyerApprovals.Add(BuyerApproval);

            return(context.SaveChanges());
        }