Пример #1
0
        public void Update(User_additional_info profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException();
            }
            var profileToUpdate = GetById(profile.UserId);

            if (profileToUpdate == null)
            {
                throw new ArgumentException
                          ($"Section with Id = {profile.UserId} does not exists");
            }

            profileToUpdate.Firstname  = profile.Firstname;
            profileToUpdate.Lastname   = profile.Lastname;
            profileToUpdate.Patronymic = profile.Patronymic;
            profileToUpdate.City       = profile.City;
            profileToUpdate.Country    = profile.Country;
            profileToUpdate.Adress1    = profile.Adress1;
            profileToUpdate.Adress2    = profile.Adress2;
            profileToUpdate.Birthdate  = profile.Birthdate;
            profileToUpdate.Phone      = profile.Phone;
            profileToUpdate.Describing = profile.Describing;

            ctx.Entry(profileToUpdate).State = EntityState.Modified;
            ctx.SaveChanges();
        }
Пример #2
0
 public void Add(User_additional_info profile)
 {
     if (profile == null)
     {
         throw new ArgumentNullException();
     }
     ctx.Set <User_additional_info>().Add(profile);
     ctx.SaveChanges();
 }
Пример #3
0
        public void Delete(User_additional_info profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException();
            }
            var profileToDelete = GetById(profile.UserId);

            if (profileToDelete == null)
            {
                throw new ArgumentException
                          ($"Message with Id = {profile.UserId} does not exists");
            }

            ctx.Set <User_additional_info>().Remove(profileToDelete);
            ctx.SaveChanges();
        }
Пример #4
0
 public ActionResult Account(UserViewModel uservm)
 {
     if (ModelState.IsValid)
     {
         if (uservm.File != null)
         {
             byte[] image;
             using (var binaryReader = new BinaryReader(uservm.File.InputStream))
             {
                 image = binaryReader.ReadBytes(uservm.File.ContentLength);
             }
             Domain.ORMEntities.User user = new Domain.ORMEntities.User {
                 UserId = uservm.Id, Image = image
             };
             _repository.UpdateUser(user);
         }
         User_additional_info info = uservm.GetAdditionalInfo();
         profileReposiory.Update(info);
         return(RedirectToRoute("UserProfile", new { username = uservm.Username }));
     }
     return(View(uservm));
 }