Exemplo n.º 1
0
        public ActionResult Index(ProfileModel model)
        {
            if (ModelState.IsValid)
            {
                var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name));
                Mapper.CreateMap<ProfileModel, User>();
                Mapper.Map<ProfileModel, User>(model, curUser);

                if (model.Resume != null)
                {
                    model.ResumePath = this.SaveResumeFile(model.Resume);
                }

                Mapper.CreateMap<ProfileModel, Profile>();
                if (curUser.Profile != null)
                {
                    Mapper.Map<ProfileModel, Profile>(model, curUser.Profile);
                }
                else
                {
                    var profile = new Profile();
                    Mapper.Map<ProfileModel, Profile>(model, profile);
                    curUser.Profile = profile;
                }

                this.profilesRepo.SaveOrUpdate(curUser.Profile);
                this.usersRepo.SaveOrUpdate(curUser);

                return RedirectToAction("Index");
            }

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Index(ProfileModel model)
        {
            if (ModelState.IsValid)
            {
                var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name));
                Mapper.CreateMap <ProfileModel, User>();
                Mapper.Map <ProfileModel, User>(model, curUser);

                if (model.Resume != null)
                {
                    model.ResumePath = this.SaveResumeFile(model.Resume);
                }

                Mapper.CreateMap <ProfileModel, Profile>();
                if (curUser.Profile != null)
                {
                    Mapper.Map <ProfileModel, Profile>(model, curUser.Profile);
                }
                else
                {
                    var profile = new Profile();
                    Mapper.Map <ProfileModel, Profile>(model, profile);
                    curUser.Profile = profile;
                }

                this.profilesRepo.SaveOrUpdate(curUser.Profile);
                this.usersRepo.SaveOrUpdate(curUser);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }