public void UserTypeDtoConstructorTest() { int id = 0; // TODO: Initialize to an appropriate value string userTypeName = string.Empty; // TODO: Initialize to an appropriate value UserTypeDto target = new UserTypeDto(id, userTypeName); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// Delete specified user type from database /// </summary> /// <param name="user">dto User type data</param> public void DeleteUserType(UserTypeDto 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.UserTypes); //Find user type which has been deleted. UserType existingUserType = (UserType)dbContext.UserTypes.Single(u => u.Id == dto.Id); //If required user doesn't exists, throw exception. if (existingUserType == null) { throw new Exception("User type does not exist"); } //else perform deleting from database else { //Delete user. dbContext.DeleteObject(existingUserType); //Saves chages. dbContext.SaveChanges(); } } catch (Exception exception) { throw new Exception("SmartGridDataMenagers: " + exception.Message); } }
public void IdTest() { UserTypeDto target = new UserTypeDto(); // 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 UserTypeNameTest() { UserTypeDto target = new UserTypeDto(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.UserTypeName = expected; actual = target.UserTypeName; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void UserTypeDtoConstructorTest1() { UserTypeDto target = new UserTypeDto(); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// Returns list of all user types from database. /// </summary> /// <returns>List list of UserTypeDto's</returns> public List<UserTypeDto> GetAllUserTypes() { //Instantiate list of dto users which has been returned. List<UserTypeDto> listDto = new List<UserTypeDto>(); 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.Users); //list of users List<UserType> list = dbContext.UserTypes.OrderBy(u => u.Id).ToList(); //filling the list foreach (UserType u in list) { UserTypeDto userTypeDto = new UserTypeDto(u.Id, u.UserTypeName); listDto.Add(userTypeDto); } } catch (Exception exception) { throw new Exception("UserTypeDataMenager: " + exception.Message); } //returns list of all users as list of dtoes. return listDto; }
/// <summary> /// Update User Type data in database /// </summary> /// <param name="dto">dto user type data</param> public void UpdateUserType(UserTypeDto 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.UserTypes); //Find user type which have to bee updated. UserType existingUserType = dbContext.UserTypes.Single(u => u.Id == dto.Id); //If required user type doesn't exists, throw exception. if (existingUserType == null) { throw new Exception("User type does not exist"); } //else prepare all data for storing to database. else { existingUserType.UserTypeName = dto.UserTypeName; } //Save changes dbContext.SaveChanges(); } catch (Exception exception) { throw new Exception("UserTypeDataMenagers: " + exception.Message); } }
/// <summary> /// Insert specified user type in database /// </summary> /// <param name="dto">dto data for user type</param> public void InsertUserType(UserTypeDto 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.UserTypes); //New user - setting data UserType u = new UserType(); u.Id = dto.Id; u.UserTypeName = dto.UserTypeName; //Adds new user to context dbContext.UserTypes.AddObject(u); //saves changes. dbContext.SaveChanges(); } catch (Exception exception) { throw new Exception("UserTypeDataMenagers: " + exception.Message); } }