Beispiel #1
0
        public ActionResult WriterProfile()
        {
            int    id = 0;
            string p  = (string)Session["WriterMail"];

            id = c.Writers.Where(x => x.WriterMail == p).Select(y => y.WriterId).FirstOrDefault();
            WriterProfileEditDto writerProfileEditDto = new WriterProfileEditDto
            {
                WriterId      = id,
                WriterMail    = wm.GetById(id).WriterMail,
                WriterName    = wm.GetById(id).WriterName,
                WriterSurname = wm.GetById(id).WriterSurname,
                WriterAbout   = wm.GetById(id).WriterAbout,
                WriterImage   = wm.GetById(id).WriterImage,
                WriterTitle   = wm.GetById(id).WriterTitle,
                WriterStatus  = wm.GetById(id).WriterStatus,
            };
            var image = wm.GetById(id).WriterImage;

            ViewBag.img = image;
            var name = wm.GetById(id).WriterName;

            ViewBag.nm = name;
            var surname = wm.GetById(id).WriterSurname;

            ViewBag.sn = surname;
            var title = wm.GetById(id).WriterTitle;

            ViewBag.tit = title;
            return(View(writerProfileEditDto));
        }
Beispiel #2
0
        public ActionResult WriterProfile(WriterProfileEditDto writerProfileEditDto)
        {
            IAuthService     authService = new AuthManager(new AdminManager(new EfAdminDal()), new WriterManager(new EfWriterDal()));
            ValidationResult results     = writervalidator.Validate(writerProfileEditDto);

            if (results.IsValid)
            {
                if (writerProfileEditDto.WriterImage != null)
                {
                    if (Request.Files.Count > 0)
                    {
                        string filesname = Path.GetFileName(Request.Files[0].FileName);
                        string extension = Path.GetExtension(Request.Files[0].FileName);
                        string road      = "~/Image/" + filesname + extension;
                        Request.Files[0].SaveAs(Server.MapPath(road));
                        writerProfileEditDto.WriterImage = "/Image/" + filesname + extension;
                    }
                }
                authService.WriterEdit(writerProfileEditDto);
                return(RedirectToAction("WriterProfile"));
            }
            else
            {
                foreach (var item in results.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }
            return(View());
        }
        public ActionResult EditWriter(int id)
        {
            WriterProfileEditDto writerProfileEditDto = new WriterProfileEditDto
            {
                WriterId      = id,
                WriterMail    = wm.GetById(id).WriterMail,
                WriterName    = wm.GetById(id).WriterName,
                WriterSurname = wm.GetById(id).WriterSurname,
                WriterAbout   = wm.GetById(id).WriterAbout,
                WriterImage   = wm.GetById(id).WriterImage,
                WriterTitle   = wm.GetById(id).WriterTitle,
                WriterStatus  = wm.GetById(id).WriterStatus,
            };

            return(View(writerProfileEditDto));
        }
        public void WriterAdd(WriterProfileEditDto writerProfileEditDto)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.WriterCreatePasswordHash(writerProfileEditDto.WriterPassword, out passwordHash, out passwordSalt);
            var writer = new Writer
            {
                WriterName         = writerProfileEditDto.WriterName,
                WriterSurname      = writerProfileEditDto.WriterSurname,
                WriterMail         = writerProfileEditDto.WriterMail,
                WriterPasswordHash = passwordHash,
                WriterPasswordSalt = passwordSalt,
                WriterAbout        = writerProfileEditDto.WriterAbout,
                WriterImage        = writerProfileEditDto.WriterImage,
                WriterStatus       = true,
                WriterTitle        = writerProfileEditDto.WriterTitle,
            };

            _writerService.WriterAdd(writer);
        }