示例#1
0
        public ActionResult EditProfile()
        {
            Guid   userId = new Guid(User.Identity.Name);
            User   user   = db.Users.Find(userId);
            Seller seller = db.Sellers.Where(current => !current.IsDeleted && current.UserId == userId).FirstOrDefault();

            List <SelectListItem> Gender = new List <SelectListItem>();

            Gender.Add(new SelectListItem()
            {
                Text = "مرد", Value = "false"
            });
            Gender.Add(new SelectListItem()
            {
                Text = "زن", Value = "true"
            });
            ViewBag.Gender = new SelectList(Gender, "Value", "Text", user.Gender);

            SellerProfileViewModel sellerProfile = new SellerProfileViewModel()
            {
                Fullname = user.FullName,
                Email    = user.Email,
                Password = user.Password,
                CellNum  = user.CellNum,

                BirthDate     = user.BirthDate,
                BirthLocation = user.BirthLocation,
                //Gender = user.Gender,
                Phone           = user.Phone,
                ZipCode         = user.ZipCode,
                CurrentProvince = user.CurrentProvince,
                Address         = user.Address,


                Title     = seller.Title,
                ImageUrl  = seller.ImageUrl,
                StartDate = seller.StartDate,
                Body      = seller.Body,
                ResumeUrl = seller.ResumeUrl,

                Education = seller.Education,
                ArtField  = seller.ArtField,
                ParticipatingDomesticExhibitions = seller.ParticipatingDomesticExhibitions,
                ParticipatingForeignExhibitions  = seller.ParticipatingForeignExhibitions,
                MethodOfIntroduction             = seller.MethodOfIntroduction,
                Summery = seller.Summery,

                UserId   = user.Id,
                SellerId = seller.Id
            };

            TempData["SizeError"] = "";
            return(View(sellerProfile));
        }
示例#2
0
        public ActionResult EditProfile(SellerProfileViewModel profile, HttpPostedFileBase fileupload, HttpPostedFileBase resumeupload)
        {
            if (ModelState.IsValid)
            {
                Seller seller = db.Sellers.Find(profile.SellerId);
                User   user   = db.Users.Find(profile.UserId);
                List <SelectListItem> Gender = new List <SelectListItem>();
                Gender.Add(new SelectListItem()
                {
                    Text = "مرد", Value = "false"
                });
                Gender.Add(new SelectListItem()
                {
                    Text = "زن", Value = "true"
                });
                ViewBag.Gender = new SelectList(Gender, "Value", "Text", profile.Gender);

                #region Upload and resize image if needed
                if (fileupload != null)
                {
                    if (fileupload.ContentLength > 4194304)
                    {
                        TempData["SizeError"] = @"<div class='alert alert-danger'>فایل بارگزاری شده نباید بیشتر از 4 مگابایت باشد</div>";
                        return(View(profile));
                    }
                    string filename    = Path.GetFileName(fileupload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    string newFilenameUrl   = "/Uploads/seller/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);
                    fileupload.SaveAs(physicalFilename);
                    seller.ImageUrl = newFilenameUrl;
                }

                if (resumeupload != null)
                {
                    if (resumeupload.ContentLength > 4194304)
                    {
                        TempData["SizeError"] = @"<div class='alert alert-danger'>فایل بارگزاری شده نباید بیشتر از 4 مگابایت باشد</div>";
                        return(View(profile));
                    }
                    string filename    = Path.GetFileName(resumeupload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    string newFilenameUrl   = "/Uploads/seller/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);
                    resumeupload.SaveAs(physicalFilename);
                    seller.ResumeUrl = newFilenameUrl;
                }
                #endregion
                seller.Title     = profile.Title;
                seller.StartDate = profile.StartDate;
                seller.Body      = profile.Body;
                seller.IsDeleted = false;
                seller.Education = profile.Education;
                seller.ArtField  = profile.ArtField;
                seller.ParticipatingDomesticExhibitions = profile.ParticipatingDomesticExhibitions;
                seller.ParticipatingForeignExhibitions  = profile.ParticipatingForeignExhibitions;
                seller.MethodOfIntroduction             = profile.MethodOfIntroduction;
                seller.Summery         = profile.Summery;
                seller.IsActive        = false;
                db.Entry(seller).State = EntityState.Modified;

                user.FullName        = profile.Fullname;
                user.Email           = profile.Email;
                user.Password        = profile.Password;
                user.CellNum         = profile.CellNum;
                user.IsDeleted       = false;
                user.BirthDate       = profile.BirthDate;
                user.BirthLocation   = profile.BirthLocation;
                user.Gender          = profile.Gender;
                user.Phone           = profile.Phone;
                user.ZipCode         = profile.ZipCode;
                user.CurrentProvince = profile.CurrentProvince;
                user.Address         = profile.Address;
                db.Entry(user).State = EntityState.Modified;

                DeActiveSellerProducts(seller.Id);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(profile));
        }
示例#3
0
 public SellerProfile(userModel usuarioPerfil)
 {
     InitializeComponent();
     BindingContext = this.ViewModel = new SellerProfileViewModel(usuarioPerfil);
 }
示例#4
0
        public SellerProfile(SellerProfileViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = this.ViewModel = viewModel;
        }