コード例 #1
0
 public ActionResult RegisterSeller(Seller s)
 {
     try
     {
         _context.Add(s);
         _context.SaveChanges();
         ViewBag.message = s.Username + "has got successfully registered";
         return(RedirectToAction("SellerLogin"));
     }
     catch (Exception e)
     {
         ViewBag.message = s.Username + "Registration failed ";
         return(View());
     }
 }
コード例 #2
0
        public ActionResult Register(SellerCreatePath b)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;

                // If the Photo property on the incoming model object is not null, then the user
                // has selected an image to upload.
                if (b.photo != null)
                {
                    // The image must be uploaded to the images folder in wwwroot
                    // To get the path of the wwwroot folder we are using the inject
                    // HostingEnvironment service provided by ASP.NET Core
                    string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
                    // To make sure the file name is unique we are appending a new
                    // GUID value and and an underscore to the file name
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + b.photo.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                    // Use CopyTo() method provided by IFormFile interface to
                    // copy the file to wwwroot/images folder
                    b.photo.CopyTo(new FileStream(filePath, FileMode.Create));
                }

                Seller newEmployee = new Seller
                {
                    Sid   = b.Sid,
                    SName = b.Sname,
                    Pass  = b.Pass,
                    Email = b.Email,
                    Phno  = b.Mobile,
                    date  = b.date,
                    // Store the file name in PhotoPath property of the employee object
                    // which gets saved to the Employees database table
                    Photopath = uniqueFileName
                };

                _context.Add(newEmployee);
                _context.SaveChanges();
                return(RedirectToAction("Details", new { id = newEmployee.Sid }));
            }

            return(View());

            //try
            //{

            //    _context.Add(b);
            //    _context.SaveChanges();
            //    ViewBag.message = b.SName + " successfully registered";
            //    return RedirectToAction("Login");

            //}
            //catch (Exception e)
            //{

            //    ViewBag.message = b.SName + " registration failed";
            //    return View();
            //}
        }
コード例 #3
0
        public IActionResult RegisterSeller(SellercreatePath s)
        {
            string uniqueFileName = null;

            if (ModelState.IsValid)
            {
                // If the Photo property on the incoming model object is not null, then the user
                // has selected an image to upload.
                if (s.Photopath != null)
                {
                    // The image must be uploaded to the images folder in wwwroot
                    // To get the path of the wwwroot folder we are using the inject
                    // HostingEnvironment service provided by ASP.NET Core
                    string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "Images");
                    // To make sure the file name is unique we are appending a new
                    // GUID value and and an underscore to the file name
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + s.Photopath.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                    // Use CopyTo() method provided by IFormFile interface to
                    // copy the file to wwwroot/images folder
                    s.Photopath.CopyTo(new FileStream(filePath, FileMode.Create));
                }


                Seller newseller = new Seller
                {
                    Uname     = s.Uname,
                    Email     = s.Email,
                    Pwd       = s.Pwd,
                    C_name    = s.C_name,
                    s_id      = s.s_id,
                    C_No      = s.C_No,
                    GSTIN     = s.GSTIN,
                    Photopath = uniqueFileName
                };
                try
                {
                    _context.Add(newseller);
                    _context.SaveChanges();

                    ViewBag.message = newseller.Uname + "Successfully registerd";
                }
                catch (Exception e)
                {
                    ViewBag.message = newseller.Uname + "Failed to register";
                }
                return(RedirectToAction("SellerLogin", new { id = newseller.s_id }));
            }
            else
            {
                return(View());
            }
        }
コード例 #4
0
 public ActionResult RegisterSeller(Seller uc)
 {
     try
     {
         _scontext.Add(uc);
         _scontext.SaveChanges();
         ViewBag.message = uc.Name + "has successfully registered";
         return(RedirectToAction(""));
     }
     catch (Exception e)
     {
         ViewBag.message = uc.Name + "Registration failed";
     }
     return(View());
 }
コード例 #5
0
 public ActionResult Register(Seller Sell)
 {
     try
     {
         _Context.Add(Sell);
         _Context.SaveChanges();
         ViewBag.message = "Hi " + Sell.SUname + "\n You are Successfully Registered.";
         //return RedirectToAction("Login");
         return(View());
     }
     catch (Exception e)
     {
         ViewBag.message = "Sorry " + Sell.SUname + "\n You are Not Successfully Registered.\n try again after Sometime.";
         return(View());
     }
 }
コード例 #6
0
        public ActionResult RegisterSeller(SellerCreateView model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;

                // If the Photo property on the incoming model object is not null, then the user
                // has selected an image to upload.
                if (model.PhotoPath != null)
                {
                    // The image must be uploaded to the images folder in wwwroot
                    // To get the path of the wwwroot folder we are using the inject
                    // HostingEnvironment service provided by ASP.NET Core
                    string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "Images");
                    // To make sure the file name is unique we are appending a new
                    // GUID value and and an underscore to the file name
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + model.PhotoPath.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                    // Use CopyTo() method provided by IFormFile interface to
                    // copy the file to wwwroot/images folder
                    model.PhotoPath.CopyTo(new FileStream(filePath, FileMode.Create));
                }

                Seller newseller = new Seller
                {
                    Sname         = model.Sname,
                    Password      = model.Password,
                    PostalAddress = model.PostalAddress,
                    Email         = model.Email,
                    Website       = model.Website,
                    Companyname   = model.Companyname,
                    Bankdetails   = model.Bankdetails,

                    // Store the file name in PhotoPath property of the employee object
                    // which gets saved to the Employees database table
                    PhotoPath = uniqueFileName
                };

                _context.Add(newseller);
                _context.SaveChanges();
                return(RedirectToAction("Details", new { id = newseller.Sid }));
            }

            return(View());
        }