public ActionResult MakeOrder(RegistrationVM model) { string productsId = Session["OrderProduct"].ToString(); string quantities = Session["ProductQuantity"].ToString(); string userID = Session["User_ID"].ToString(); string[] keyProduct = productsId.Split(','); string[] keyQuantity = quantities.Split(','); User user = new User(); UserServise _user = new UserServise(); if (userID != null) { EncriptServises _encript = new EncriptServises(); for (int i = 0; i < keyProduct.Length - 1; i++) { Order entity = new Order(); entity.SubjectID = int.Parse(keyProduct[i]); entity.Quantity = int.Parse(keyQuantity[i]); entity.OrderNumber = Session["OrderNumber"].ToString(); entity.Date = DateTime.Today.ToString("dd/MM/yyyy"); entity.Status = Status.Supplier; Product element = _product.GetByID(entity.SubjectID); entity.Total = (entity.Quantity * element.Price); _order.Save(entity); entity.UserID = int.Parse(userID); _order.Save(entity); ChangewquantityOfPRoduct(element, entity.Quantity); } } else { user = AddUserInDB(user, model); _user.Save(user); user = new User(); for (int i = 0; i < keyProduct.Length - 1; i++) { Order entity = new Order(); entity.SubjectID = int.Parse(keyProduct[i]); entity.Quantity = int.Parse(keyQuantity[i]); entity.OrderNumber = Session["OrderNumber"].ToString(); entity.Date = DateTime.Today.ToString("dd/MM/yyyy"); entity.Status = Status.Supplier; user = _user.GetLastElement(); entity.UserID = user.ID; Product element = _product.GetByID(entity.SubjectID); entity.Total = (entity.Quantity * element.Price); _order.Save(entity); ChangewquantityOfPRoduct(element, entity.Quantity); } } DeleteSession(); return(RedirectToAction("CungratOrder")); }
private User AddUserInDB(User user, RegistrationVM model) { EncriptServises _encript = new EncriptServises(); user.Name = _encript.EncryptData(model.FirstName); user.SecondName = _encript.EncryptData(model.SecondName); user.City = _encript.EncryptData(model.City); user.Adress = _encript.EncryptData(model.Adress); user.Telephone = _encript.EncryptData(model.Telephone); return(user); }
private User PopulateUser(Order order) { User entity = new User(); UserServise _user = new UserServise(); EncriptServises _encript = new EncriptServises(); var model = _user.GetByID(order.UserID); entity.Name = _encript.DencryptData(model.Name); entity.SecondName = _encript.DencryptData(model.SecondName); entity.City = _encript.DencryptData(model.City); entity.Adress = _encript.DencryptData(model.Adress); entity.Telephone = _encript.DencryptData(model.Telephone); return(entity); }
public ActionResult MakeOrder() { RegistrationVM model = new RegistrationVM(); string userID = Session["User_ID"].ToString(); if (userID != null) { UserServise _login = new UserServise(); EncriptServises _encript = new EncriptServises(); User user = new User(); user = _login.GetByID(int.Parse(userID)); model.FirstName = _encript.DencryptData(user.Name); model.SecondName = _encript.DencryptData(user.SecondName); model.City = _encript.DencryptData(user.City); model.Adress = _encript.DencryptData(user.Adress); model.Telephone = _encript.DencryptData(user.Telephone); ViewData["Information"] = "Вие имате регистрация в нашия сайт! Моля натиснете бътона 'Поръчай', за да направите поръчката си!"; } else { ViewData["Information"] = "Моля въведете информацията която се изисква за да направите вашата поръчка!"; } return(View(model)); }
public CoockieServises() { _cript = new EncriptServises(); }