public ActionResult Save(SignupModel obj) { int userId = 0; var check = true; TempData["Message"] = ""; obj.Password = Guid.NewGuid().ToString().Substring(0, 6); obj.Isadmin = false; if (obj.id > 0) { check = UserDal.Update(obj); } else { check = UserDal.Create(obj, out userId); } check = OrderDal.UpdateUserAddressInOrder(new OrderHeader { Userid=userId, Address1 = obj.Address1, Address2 = obj.Address2, City = obj.City, ContactNumber = obj.ContactNumber, Country = obj.Country, DAddress1 = obj.DAddress1, DAddress2 = obj.DAddress2, DCity = obj.DCity, DCountry = obj.DCountry, DPostCode = obj.DPostCode, DState = obj.DState, Email = obj.Email, Name = obj.Name, PostCode = obj.PostCode, State = obj.State, orderID = Convert.ToInt32(Session["OrderId"]) }); if (check) { TempData["Message"] = "Saved Successfully"; // Take reference from other web site } else { TempData["Message"] = "Error! Unable to save"; // Take reference from other web site } return RedirectToAction("IPIN","Payment"); }
// // GET: /Checkout/ public ActionResult Index(string id) { var user = new SignupModel(); ViewBag.DeliveryDays = DeliveryDal.GetDefault(); ViewBag.RemoveDelete = "yes"; ViewBag.id = 0; ViewBag.Faq = StaticPagesDal.GetBygroupId("Faq"); if (TempData != null) { if (TempData["Invalidlogin"] == "Invalid Username and password") { return View(); } } if (Request.IsAuthenticated) { if (GetLoginUserdata().id > 0) { ViewBag.id = GetLoginUserdata().id; id = Convert.ToString(ViewBag.id); } } ViewBag.User = new Ecommerce.Model.SignupModel(); if (id != null) { user = UserDal.GetById(Convert.ToInt32(id)); ViewBag.User = user; ViewBag.id = user.id; } if (String.IsNullOrEmpty(Convert.ToString(Session["OrderId"]))) { Session["OrderId"] = CartDal.SaveOrUpdateCartAsOrder((CartModel)Session["Cart"], Convert.ToString(Session["currency"]), user.id, 0); } else { Session["OrderId"] = CartDal.SaveOrUpdateCartAsOrder((CartModel)Session["Cart"], Convert.ToString(Session["currency"]), user.id, Convert.ToInt32(Session["OrderId"])); } var OrderId = new HttpCookie("OrderId") { Value = Session["OrderId"].ToString() }; Response.SetCookie(OrderId); return View(); }
public static bool Create(SignupModel obj, out int userid) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); var user =new DbEntity.user(); user.Address1 = obj.Address1; user.Address2 = obj.Address2; user.City = obj.City; user.ContactNumber = obj.ContactNumber; user. Country = obj.Country; user. DAddress1 = obj.DAddress1; user. DAddress2 = obj.DAddress2; user. DCity = obj.DCity; user. DCountry = obj.DCountry; user. DName = obj.DName; user. DPostCode = obj.DPostCode; user. DState = obj.DState; user. Email = obj.Email; user. Name = obj.Name; user. Password = obj.Password; user. PostCode = obj.PostCode; user. State = obj.State; user. Isadmin=obj.Isadmin; context.users.Add(user); context.SaveChanges(); userid = user.id; } catch (Exception ex) { userid = 0; check = false; } return check; }
public static SignupModel ValidateUser(LoginModel loginobj) { SignupModel User = null; var context = new Ecommerce.DbEntity.ecommerceEntities(); var obj = context.users.Where(m => m.Email == loginobj.Email && m.Password == loginobj.Password&&m.Isadmin==loginobj.isadmin).FirstOrDefault(); if (obj != null) { User = new SignupModel(); User.Address1 = obj.Address1; User.Address2 = obj.Address2; User.City = obj.City; User.ContactNumber = obj.ContactNumber; User.Country = obj.Country; User.DAddress1 = obj.DAddress1; User.DAddress2 = obj.DAddress2; User.DCity = obj.DCity; User.DCountry = obj.DCountry; User.DName = obj.DName; User.DPostCode = obj.DPostCode; User.DState = obj.DState; User.Email = obj.Email; User.Name = obj.Name; User.Password = obj.Password; User.PostCode = obj.PostCode; User.State = obj.State; User.id = obj.id; } return User; }
public static bool Update(SignupModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); var User = context.users.Where(m => m.id == obj.id).FirstOrDefault(); User.Address1 = obj.Address1; User.Address2 = obj.Address2; User.City = obj.City; User.ContactNumber = obj.ContactNumber; User.Country = obj.Country; User.DAddress1 = obj.DAddress1; User.DAddress2 = obj.DAddress2; User.DCity = obj.DCity; User.DCountry = obj.DCountry; User.DName = obj.DName; User.DPostCode = obj.DPostCode; User.DState = obj.DState; User.Email = obj.Email; User.Name = obj.Name; //User.Password = obj.Password; User.PostCode = obj.PostCode; User.State = obj.State; User.Isadmin = obj.Isadmin; context.SaveChanges(); } catch (Exception ex) { check = false; } return check; }
public static SignupModel GetById(int id) { var context = new Ecommerce.DbEntity.ecommerceEntities(); var obj = context.users.Where(m => m.id == id).FirstOrDefault(); var User = new SignupModel(); User.Address1 = obj.Address1; User.Address2 = obj.Address2; User.City = obj.City; User.ContactNumber = obj.ContactNumber; User.Country = obj.Country; User.DAddress1 = obj.DAddress1; User.DAddress2 = obj.DAddress2; User.DCity = obj.DCity; User.DCountry = obj.DCountry; User.DName = obj.DName; User.DPostCode = obj.DPostCode; User.DState = obj.DState; User.Email = obj.Email; User.Name = obj.Name; User.Password = obj.Password; User.PostCode = obj.PostCode; User.State = obj.State; User.id = obj.id; User.Isadmin = Convert.ToBoolean(obj.Isadmin); return User; }