public void AddContact(User_sContact contact) { if (contact != null) { contact.Id = Guid.NewGuid(); _contactRepository.AddContact(contact); } }
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(); }
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); } }
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"); }
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")); }
public void AddContact(User_sContact contact) { _context.User_sContact.Add(contact); base.Save(); }