/// <summary> /// Delete specified personal user details from database /// </summary> /// <param name="user">dto Personal User details</param> public void DeleteUsersPersonalDetails(UserPersonalDetailsDto dto) { try { //Before any action, it must be updated because calls from contract uses //only one instance of UserManager. dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.PersonalUserDetails); //Find user which have to be deleted. PersonalUserDetail existingUserPersonalDetails = dbContext.PersonalUserDetails.Single(pud => pud.UserId == dto.UserId); //If required user doesn't exists, throw exception. if (existingUserPersonalDetails == null) { throw new Exception("User does not exist"); } //else perform deleting form database else { //Delete personal user details. dbContext.DeleteObject(existingUserPersonalDetails); //Saves chages. dbContext.SaveChanges(); } } catch (Exception exception) { throw new Exception("UserDataMenagers: " + exception.Message); } }
public void LastNameTest() { UserPersonalDetailsDto target = new UserPersonalDetailsDto(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.LastName = expected; actual = target.LastName; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void IdTest() { UserPersonalDetailsDto target = new UserPersonalDetailsDto(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; target.Id = expected; actual = target.Id; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void UserPersonalDetailsDtoConstructorTest1() { UserPersonalDetailsDto target = new UserPersonalDetailsDto(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void UserPersonalDetailsDtoConstructorTest() { int id = 0; // TODO: Initialize to an appropriate value string firstName = string.Empty; // TODO: Initialize to an appropriate value string lastName = string.Empty; // TODO: Initialize to an appropriate value string socSecNumber = string.Empty; // TODO: Initialize to an appropriate value int uId = 0; // TODO: Initialize to an appropriate value UserPersonalDetailsDto target = new UserPersonalDetailsDto(id, firstName, lastName, socSecNumber, uId); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// Returns list of all personal users details from database. /// </summary> /// <returns>List list of PersonalUsersDetailsDto's</returns> public List<UserPersonalDetailsDto> GetAllUsersPersonalDetails() { //Instantiate list of dto users which has been returned. List<UserPersonalDetailsDto> listDto = new List<UserPersonalDetailsDto>(); try { //Before any action, it must be updated because calls from contract uses //only one instance of UserManager. dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.PersonalUserDetails); //list of personal users details from entities List<PersonalUserDetail> list = dbContext.PersonalUserDetails.OrderBy(pud => pud.UserId).ToList(); //filling the list foreach (PersonalUserDetail pud in list) { UserPersonalDetailsDto personalUserDetailsDto = new UserPersonalDetailsDto (pud.Id, pud.FirstName, pud.LastName, pud.SocialSecurityNumber, pud.UserId); listDto.Add(personalUserDetailsDto); } } catch (Exception exception) { throw new Exception("SmartGridDataMenagers: " + exception.Message); } //returns list of all users personal detail as list of dtoes. return listDto; }
/// <summary> /// Update User personal details in database /// </summary> /// <param name="dto">dto personal user details</param> public void UpdateUserPersonalDetails(UserPersonalDetailsDto dto) { try { //Before any action, it must be updated because calls from contract uses //only one instance of UserManager. dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.PersonalUserDetails); //Find user which have to be updated. PersonalUserDetail existingUserPersonalDetails = dbContext.PersonalUserDetails.Single(pud => pud.UserId == dto.UserId); //If required user doesn't exists, throw exception. if (existingUserPersonalDetails == null) { throw new Exception("User does not exist"); } //else prepare all data for storing to database else { existingUserPersonalDetails.FirstName = dto.FirstName; existingUserPersonalDetails.LastName = dto.LastName; existingUserPersonalDetails.SocialSecurityNumber = dto.SocSecNumber; existingUserPersonalDetails.UserId = dto.UserId; } //Save changes dbContext.SaveChanges(); } catch (Exception exception) { throw new Exception("UserDataMenagers: " + exception.Message); } }
/// <summary> /// Insert specified user personal details in database /// </summary> /// <param name="dto">dto data for user personal details</param> public void InsertUsersPersonalDetails(UserPersonalDetailsDto dto) { try { //Before any action, it must be updated because calls from contract uses //only one instance of UserManager. dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.PersonalUserDetails); //New personal user details - setting data PersonalUserDetail pud = new PersonalUserDetail(); pud.FirstName = dto.FirstName; pud.LastName = dto.LastName; pud.SocialSecurityNumber = dto.SocSecNumber; pud.UserId = dto.UserId; //Adds new personal userdetails to context dbContext.PersonalUserDetails.AddObject(pud); //saves changes. dbContext.SaveChanges(); } catch (Exception exception) { throw new Exception("UserDataMenagers: " + exception.Message); } }