Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ImageId,Images,ProductName,ProductDescp,BidAmount,AuctionDate,Category")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Product product)
        {
            if (ModelState.IsValid)
            {
                product.Id = 123;
                db.Entry(product).State = EntityState.Modified;

                db.SaveChanges();
            }
            return(View(product));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Email,CNIC,Adress,Password")] RegisteredUser registeredUser)
        {
            if (ModelState.IsValid)
            {
                db.RegisteredUsers.Add(registeredUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(registeredUser));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,Subject,Description, FK_ID")] Feedbackss feedbackss)
        {
            Feedbackss fb = new Feedbackss();


            if (ModelState.IsValid)
            {
                fb.ID          = feedbackss.ID;
                fb.Description = feedbackss.Description;
                fb.Subject     = feedbackss.Subject;

                feedbackss.FK_ID = 12;
                db.Feedbacksses.Add(feedbackss);
                db.SaveChanges();
                return(RedirectToAction("MyProducts", "Registerss"));
            }

            //ViewBag.FK_ID = new SelectList(db.AspNetUsers, "Id", feedbackss.FK_ID);
            return(View(feedbackss));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    onlineEntities db          = new onlineEntities();
                    RegisteredUser user4       = new RegisteredUser();
                    var            userdbmodel = db.AspNetUsers.Where(a => a.Email.Equals(model.Email)).FirstOrDefault();
                    user4.Id       = model.Id;
                    user4.Name     = model.Name;
                    user4.Email    = model.Email;
                    user4.CNIC     = model.CNIC;
                    user4.Adress   = model.Address;
                    user4.Password = model.Password;

                    //user4.FK_R_ID = userdbmodel.Id;
                    db.RegisteredUsers.Add(user4);
                    db.SaveChanges();



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

            // If we got this far, something failed, redisplay for
            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult Create(ProductViewModel productss)
        {
            try
            {
                string filename  = Path.GetFileNameWithoutExtension(productss.ImageFile.FileName);
                string extension = Path.GetExtension(productss.ImageFile.FileName);
                filename         = filename + DateTime.Now.ToString("yymmssfff") + extension;
                productss.Images = "~/images/" + filename;
                filename         = Path.Combine(Server.MapPath("~/images/"), filename);
                productss.ImageFile.SaveAs(filename);

                using (onlineEntities db = new onlineEntities())
                {
                    if (db.Products.Any(x => x.ProductName == productss.ProductName))
                    {
                        ViewBag.DuplicateMessage = "Product Already exists";
                        return(View(productss));
                    }
                    Product p = new Product();
                    p.ProductName  = productss.ProductName;
                    p.ProductDescp = productss.ProductDescp;
                    p.ImageId      = productss.ImageId;
                    p.Images       = productss.Images;
                    p.Category     = productss.Category;
                    p.BidAmount    = productss.BidAmount;
                    p.AuctionDate  = productss.AuctionDate;
                    p.Id           = 12;

                    db.Products.Add(p);
                    db.SaveChanges();
                }
                //var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                //var result = await UserManager.CreateAsync(user, model.Password);
            }
            catch (Exception ex)
            {
                return(View(ex));
            }
            ModelState.Clear();
            ViewBag.SuccessMessage = "Successful";
            return(RedirectToAction("Index2"));
        }
Ejemplo n.º 7
0
        public ActionResult Create(RegisterViewModel registeredUser)
        {
            try
            {
                RegisteredUser obj = new RegisteredUser();
                obj.Id       = ii;
                obj.Name     = registeredUser.Name;
                obj.Password = registeredUser.Password;
                obj.Email    = registeredUser.Email;
                obj.Adress   = registeredUser.Address;
                obj.CNIC     = registeredUser.CNIC;
                dbb.RegisteredUsers.Add(obj);
                ii++;
                dbb.SaveChanges();


                return(RedirectToAction("Login", "Registerss"));
            }catch (Exception ex)
            {
                return(View(ex));
            }
        }