Exemplo n.º 1
0
 public void AddContact(User_sContact contact)
 {
     if (contact != null)
     {
         contact.Id = Guid.NewGuid();
         _contactRepository.AddContact(contact);
     }
 }
Exemplo n.º 2
0
        public void Update(User_sContact contact)
        {
            //_context.User_sContact.Attach(contact);
            //_context.Entry(contact).State = System.Data.Entity.EntityState.Modified;
            var cont = _context.User_sContact.Find(contact.Id);

            _context.Entry(cont).CurrentValues.SetValues(contact);
            base.Save();
        }
Exemplo n.º 3
0
        public void EditProfile(Aducation aducation, User_sContact contact, User_sPersonalData data, User user)
        {
            if (user != null)
            {
                var us       = GetUserById(user.Id);
                var persData = GetUserPersData(us.PersonalDataId);
                var cont     = GetContactById(us.ContactId);

                if (cont.Id != null)
                {
                    contact.Id = cont.Id;
                    _contactRepository.Update(contact);
                }
                else
                {
                    contact.Id = Guid.NewGuid();
                    _contactRepository.AddContact(contact);
                    us.ContactId = contact.Id;
                }



                if (persData.AducationId != null)
                {
                    aducation.Id = (Guid)persData.AducationId;
                    _aducationRepository.UpdateAducation(aducation);
                }
                else
                {
                    aducation.Id = Guid.NewGuid();
                    _aducationRepository.AddAducation(aducation);
                    persData.AducationId = aducation.Id;
                }

                data.Id          = persData.Id;
                data.ImageId     = persData.ImageId;
                data.AducationId = aducation.Id;
                _persDataRepository.Update(data);

                user.Id             = us.Id;
                user.PersonalDataId = data.Id;
                user.ContactId      = contact.Id;
                _userRepository.Update(user);
            }
        }
Exemplo n.º 4
0
        public ActionResult EditUser(UserIndexViewModel model)
        {
            if (ModelState.IsValid)
            {
                Aducation aducation = new Aducation()
                {
                    Type           = model.Type,
                    Institution    = model.Specialization,
                    StartYear      = model.StartYear,
                    GradYear       = model.GradYear,
                    Specialization = model.Specialization
                };
                User_sContact contact = new User_sContact()
                {
                    PhoneNumber = model.PhoneNumber,
                    Skype       = model.Skype
                };
                User_sPersonalData data = new User_sPersonalData()
                {
                    Name = model.Name
                };
                User user = new User()
                {
                    AspUserId = model.AspUserId,
                    Id        = model.Id
                };

                _userService.EditProfile(aducation, contact, data, user);
                return(RedirectToAction("Index", "User"));
            }
            else
            {
                // var model = GetProfileFromPage();

                return(View("EditUser", model));
            }



            //return RedirectToAction("Index", "User");
        }
Exemplo n.º 5
0
        public ActionResult AddUser(AddUserViewModel model)
        {
            if (model != null)
            {
                Image image = new Image()
                {
                    Image1 = _userService.СonvertingImg(model.Image)
                };
                _userService.AddImage(image);


                User_sPersonalData data = new User_sPersonalData()
                {
                    Name    = model.Name,
                    ImageId = image.Id
                };

                _userService.AddPersData(data);

                User_sContact contact = new User_sContact()
                {
                    PhoneNumber = model.PhoneNumber,
                    Skype       = model.Skype
                };
                _userService.AddContact(contact);

                User user = new User()
                {
                    PersonalDataId = data.Id,
                    ContactId      = contact.Id,
                    Visibility     = true,
                    AspUserId      = model.AspUserId
                };
                _userService.AddUser(user);
            }
            return(View("DisplayEmail"));
        }
Exemplo n.º 6
0
 public void AddContact(User_sContact contact)
 {
     _context.User_sContact.Add(contact);
     base.Save();
 }