public ActionResult Register(User U)
        {
            if (ModelState.IsValidField("EmailID") && ModelState.IsValidField("Password") && ModelState.IsValidField("FullName"))

            {
                using (UserDBEntities1 dc = new UserDBEntities1())
                {
                    var count = dc.Users.Where(s => s.EmailID == U.EmailID).Count();
                    if (count > 0)
                    {
                        ViewBag.Message = "User already exists";

                        return(View("Register", U));
                    }
                    //you should check duplicate registration here

                    int id = dc.Users.Max(u => u.UserID);
                    U.UserID = ++id;
                    dc.Users.Add(U);
                    dc.SaveChanges();
                    ModelState.Clear();
                    U = null;
                    ViewBag.Message = "Successfully Registration Done";
                }
            }

            return(View(U));
        }
        public ActionResult Edit1(int id)
        {
            UserDBEntities1  db  = new UserDBEntities1();
            CollectionTable  art = db.CollectionTables.Where(u => u.Id == id).Single();
            CollectionEditVM collectionDetailsVM = new CollectionEditVM(art);

            return(View("Edit1", collectionDetailsVM));
        }
        public ActionResult Details1(int id)
        {
            ViewBag.Message = "Details about the art.";
            var                 db  = new UserDBEntities1();
            CollectionTable     art = db.CollectionTables.Where(u => u.Id == id).Single();
            CollectionDetailsVM collectionDetailsVM = new CollectionDetailsVM(art);

            return(View("Details1", collectionDetailsVM));
        }
        public ActionResult Remove1(int id)
        {
            UserDBEntities1 db  = new UserDBEntities1();
            CollectionTable art = db.CollectionTables.Where(u => u.Id == id).Single();

            if (art != null)
            {
                db.CollectionTables.Remove(art);
            }
            db.SaveChanges();
            return(Collection());
        }
        public ActionResult Edit1(CollectionEditVM art)
        {
            UserDBEntities1 db          = new UserDBEntities1();
            CollectionTable artToUpdate = db.CollectionTables.Where(u => u.Id == art.Id).Single();

            artToUpdate.Title        = art.Title;
            artToUpdate.Author       = art.Author;
            artToUpdate.Director     = art.Director;
            artToUpdate.DateReleased = art.DateReleased;
            artToUpdate.Price        = art.Price;
            artToUpdate.Type         = art.Type;
            db.SaveChanges();
            return(Collection());
        }
 public ActionResult Create(CreateVM ct)
 {
     using (UserDBEntities1 db = new UserDBEntities1())
     {
         if (db.CollectionTables.Any(x => x.Title == ct.collectionTable.Title))
         {
             ViewBag.DuplicateMessage = "Item already exists.";
             return(View("Create", ct));
         }
         db.CollectionTables.Add(ct.collectionTable);
         db.SaveChanges();
     }
     ModelState.Clear();
     ViewBag.SuccessMessage = "Creation Successful.";
     return(View("Create", new CreateVM()));
 }
        public ActionResult Add(int id)
        {
            shoppingCart = (CartVM)Session["shoppingCart"];
            if (Session["shoppingCart"] == null)
            {
                Session["shoppingCart"] = new CartVM();
            }
            UserDBEntities1 db  = new UserDBEntities1();
            CollectionTable art = db.CollectionTables.Where(u => u.Id == id).Single();

            if (art != null)
            {
                shoppingCart.Add(art);
            }
            Session["shoppingCart"] = shoppingCart;
            return(Collection());
        }
Ejemplo n.º 8
0
        public List <UserData> AllUserData()
        {
            List <UserData> list   = new List <UserData>();
            UserDBEntities1 db     = new UserDBEntities1();
            var             dblist = db.User1.ToList();

            foreach (var dbobj in dblist)
            {
                UserData u = new UserData();
                u.Name          = dbobj.Name;
                u.ContactNumber = dbobj.Contact;
                //u.DateOfBirth.ToString() = dbobj.DateOfBirth;
                u.Email    = dbobj.Email;
                u.Password = dbobj.Password;
                list.Add(u);
            }
            return(list);
        }
 public ActionResult Login(User u)
 {
     // this action is for handle post (login)
     if (ModelState.IsValidField("EmailID") && ModelState.IsValidField("Password")) // this is check validity
     {
         using (UserDBEntities1 dc = new UserDBEntities1())
         {
             var v = dc.Users.Where(a => (a.EmailID.Equals(u.EmailID) && a.Password.Equals(u.Password))).FirstOrDefault();
             if (v != null)
             {
                 Session["LogedUserID"]       = v.UserID.ToString();
                 Session["LogedUserFullname"] = v.FullName.ToString();
                 Session["Email"]             = v.EmailID.ToString();
                 return(RedirectToRoute("Login", v));
             }
         }
     }
     ViewBag.Message = "No Admin with this detial";
     return(View(u));
 }