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)); }
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")); } }
public int UpdateApproval(int id, bool status) { BuyerApproval buyerApprovalToUpdate = context.BuyerApprovals.SingleOrDefault(a => a.Id == id); buyerApprovalToUpdate.Status = status; return(context.SaveChanges()); }
public int Delete(int id) { BuyerApproval buyerApprovalToDelete = context.BuyerApprovals.SingleOrDefault(a => a.Id == id); context.BuyerApprovals.Remove(buyerApprovalToDelete); return(context.SaveChanges()); }
public int Insert(BuyerApproval BuyerApproval) { context.BuyerApprovals.Add(BuyerApproval); return(context.SaveChanges()); }