Ejemplo n.º 1
0
        public IActionResult AdminCreateSeller(AdminCreateSellerViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName   = ProcessProfilPicture(model);
                string uniqueBannerName = ProcessBannerPicture(model);


                Seller newSeller = new Seller
                {
                    BusinessName   = model.BusinessName,
                    InChargePerson = model.InChargePerson,
                    Country        = model.Country,
                    Location       = model.Location,
                    Address        = model.Address,
                    Telephone      = model.Telephone,
                    Mobile         = model.Mobile,
                    Email          = model.Email,
                    Web            = model.Web,
                    PlatformCharge = model.PlatformCharge,
                    RegistredDate  = model.RegistredDate,
                    BannerImg      = uniqueBannerName,
                    ProfileImg     = uniqueFileName,
                    SalesGoodType  = model.SalesGoodType,
                    Description    = model.Description
                };

                _sallesRepository.AdminCreateSeller(newSeller);
                return(RedirectToAction("AdminDetails", new { id = newSeller.Id }));
            }

            return(View());
        }
Ejemplo n.º 2
0
        private string ProcessProfilPicture(AdminCreateSellerViewModel model)
        {
            string uniqueFileName = null;

            if (model.ProfilePic != null)
            {
                string uploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "img/Profile");
                uniqueFileName = Guid.NewGuid().ToString() + "_" + model.ProfilePic.FileName;
                string filePath = Path.Combine(uploadFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.ProfilePic.CopyTo(fileStream);
                }
            }

            return(uniqueFileName);
        }