public Profile Edit(Profile EditedProfile) { Profile original = Get(EditedProfile.UserId); original.Name = EditedProfile.Name != null ? EditedProfile.Name : original.Name; original.Email = EditedProfile.Email != null ? EditedProfile.Email : original.Email; original.Img = EditedProfile.Img != null ? EditedProfile.Img : original.Img; _repo.Edit(original); return(original); }
//ANCHOR Checks if profile is valid, Checks if user is owner of //ANCHOR of the profile, edits name and/or picture internal Profile Edit(string id, Profile userInfo, Profile editProfile) { Profile profile = _repo.GetById(id); if (profile == null) { throw new Exception("Invalid Id"); } if (userInfo.Id != id) { throw new Exception("Access Denied, this is not yours"); } editProfile.Name = editProfile.Name == null ? profile.Name : editProfile.Name; editProfile.Picture = editProfile.Picture == null ? profile.Picture : editProfile.Picture; return(_repo.Edit(editProfile)); }
// ProfileToUpdate (ptu) internal Profile Edit(Profile ptu) { Profile original = GetProfileById(ptu.Id, ptu.UserId); if (ptu == null || original.UserId != ptu.UserId) { throw new Exception("Invalid Id"); } original.FirstName = ptu.FirstName == null ? original.FirstName : ptu.FirstName; original.LastName = ptu.LastName == null ? original.LastName : ptu.LastName; original.Email = ptu.Email == null ? original.Email : ptu.Email; original.Picture = ptu.Picture == null ? original.Picture : ptu.Picture; original.Phone = ptu.Phone == null ? original.Phone : ptu.Phone; // Author/userId is not to be changed. Ever. _repo.Edit(ptu); return(original); }
public Profile Edit(Profile editProfile) { Profile profile = _repo.Get(editProfile.Id); if (profile == null) { throw new Exception("Invalid Id"); } profile.DOB = editProfile.DOB; profile.StartDate = editProfile.StartDate; profile.Height = editProfile.Height; profile.StartWeight = editProfile.StartWeight; profile.GoalWeight = editProfile.GoalWeight; profile.Gender = editProfile.Gender; _repo.Edit(profile); return(profile); }