/// <summary> /// Delete specified user contact details from database /// </summary> /// <param name="user">dto User contact details</param> public void DeleteUsersContactDetails(UserContactDetailsDto 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.UserContactDetails); //Find user contact details which have to be deleted. UserContactDetail existingUserContactDetails = dbContext.UserContactDetails.Single(cd => cd.UserId == dto.UserId); //If required user contact details doesn't exists, throw exception. if (existingUserContactDetails == null) { throw new Exception("User contact details does not exist"); } //else prepare all data for storing to database else { //Delete user contact details. dbContext.DeleteObject(existingUserContactDetails); //Saves chages. dbContext.SaveChanges(); } } catch (Exception exception) { throw new Exception("SmartGridDataMenagers: " + exception.Message); } }
public void TelephoneTest() { UserContactDetailsDto target = new UserContactDetailsDto(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.Telephone = expected; actual = target.Telephone; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void IdTest() { UserContactDetailsDto target = new UserContactDetailsDto(); // 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 UserContactDetailsDtoConstructorTest() { int id = 0; // TODO: Initialize to an appropriate value string telephone = string.Empty; // TODO: Initialize to an appropriate value string mobile = string.Empty; // TODO: Initialize to an appropriate value int uId = 0; // TODO: Initialize to an appropriate value UserContactDetailsDto target = new UserContactDetailsDto(id, telephone, mobile, uId); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void UserContactDetailsDtoConstructorTest1() { UserContactDetailsDto target = new UserContactDetailsDto(); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// Returns list of all users contact details from database. /// </summary> /// <returns>List list of UsersContactDetailsDto's</returns> public List<UserContactDetailsDto> GetAllUsersContactDetails() { //Instantiate list of dto users contact details which has been returned. List<UserContactDetailsDto> listDto = new List<UserContactDetailsDto>(); 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.UserContactDetails); //list of users contact details from entities List<UserContactDetail> list = dbContext.UserContactDetails.OrderBy(cd => cd.UserId).ToList(); //filling the list foreach (UserContactDetail cd in list) { UserContactDetailsDto userContactDetailsDto = new UserContactDetailsDto (cd.Id, cd.Telephone, cd.Mobile, cd.UserId); listDto.Add(userContactDetailsDto); } } catch (Exception exception) { throw new Exception("SmartGridDataMenagers: " + exception.Message); } //returns list of all users contact details as list of dtoes. return listDto; }
/// <summary> /// Insert specified user contact details in database /// </summary> /// <param name="dto">dto data for user contact details</param> public void InsertUsersContactDetails(UserContactDetailsDto 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.UserContactDetails); UserContactDetail cd = new UserContactDetail(); cd.Telephone = dto.Telephone; cd.Mobile = dto.Mobile; cd.UserId = dto.UserId; //Adds new user contact details to context dbContext.UserContactDetails.AddObject(cd); //saves changes. dbContext.SaveChanges(); } catch (Exception exception) { throw new Exception("UserDataMenagers: " + exception.Message); } }