Ejemplo n.º 1
0
        public ActionResult AddPicture(UserViewModel user, HttpPostedFileBase uploadImage)
        {
            if ( uploadImage != null)
            {
                byte[] imageData = null;
                using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                {
                    imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                }
                user.Image = imageData;
                user.ID = User.Identity.GetUserId();
                service.AddPicture(user);
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
 public ActionResult People(UserViewModel user)
 {
     service.UpdateWithoutAddressPhone(user);
     return RedirectToAction("People");
 }
Ejemplo n.º 3
0
 public ActionResult Index(UserViewModel user, HttpPostedFileBase uploadImage)
 {
     service.UpdateUserData(user);
     return RedirectToAction("Index");
 }
Ejemplo n.º 4
0
 public void Add(UserViewModel user)
 {
     User userR = Mapper.Map<User>(user);
     repository.Create(userR);
 }
Ejemplo n.º 5
0
 public void Delete(UserViewModel user)
 {
     User userR = Mapper.Map<User>(user);
     repository.Delete(userR);
 }
Ejemplo n.º 6
0
 public void Update(UserViewModel user)
 {
     User userR = Mapper.Map<User>(user);
     userR.people = new List<Person>();
     foreach (var per in user.people)
     {
         userR.people.Add(Mapper.Map<Person>(per));
         userR.people[userR.people.Count - 1].addresses = new List<Address>();
         foreach (var add in per.Address)
         {
             userR.people[userR.people.Count - 1].addresses.Add(Mapper.Map<Address>(add));
         }
         userR.people[userR.people.Count - 1].phonenumbers = new List<PhoneNumbers>();
         foreach (var ph in per.PhoneNumbers)
         {
             userR.people[userR.people.Count - 1].phonenumbers.Add(Mapper.Map<PhoneNumbers>(ph));
         }
     }
     repository.Update(userR);
 }
Ejemplo n.º 7
0
 public void UpdateUserData(UserViewModel user)
 {
     User userR = Mapper.Map<User>(user);
     repository.UpdateUserData(userR);
 }
Ejemplo n.º 8
0
 public void AddPicture(UserViewModel user)
 {
     User userR = Mapper.Map<User>(user);
     repository.AddPicture(userR);
 }
Ejemplo n.º 9
0
        public void UpdateWithoutAddressPhone(UserViewModel user)
        {
            User userR = Mapper.Map<User>(user);
            userR.people = new List<Person>();
            foreach (var per in user.people)
            {
                Person p = Mapper.Map<Person>(per);
                p.UserID = user.ID;
                repository.UpdateWithoutAddressPhone(p);
            }

        }
Ejemplo n.º 10
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    IUserService service = new UserService();
                    UserViewModel userNew = new UserViewModel()
                    {
                        ID = user.Id,//User.Identity.GetUserId(),
                        LogInName = user.UserName,//User.Identity.Name,
                        people = new System.Collections.Generic.List<PersonViewModel>()
                    };
                    service.Add(userNew);

                    return RedirectToAction("Index", "User", new { ID=User.Identity.GetUserId()});
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 11
0
 public ActionResult People(UserViewModel user)
 {
     service.Update(user);
     return RedirectToAction("People");
 }
Ejemplo n.º 12
0
 public ActionResult Index(UserViewModel user)
 {
     service.UpdateUserData(user);
     return RedirectToAction("Index");
 }