/// <summary> /// Adds the specified user detail. /// </summary> /// <param name="userDetail">The user detail.</param> /// <returns></returns> public Response <UserDirectReportsViewModel> Add(UserDirectReportsViewModel userDetail, bool isMyProfile) { var route = isMyProfile ? "AddMyProfile" : "Add"; var apiUrl = BaseRoute + route; var response = _communicationManager.Post <UserDirectReportsModel, Response <UserDirectReportsModel> >(userDetail.ToModel(), apiUrl); return(response.ToViewModel()); }
public void Add_Failure() { // Arrange var userReport = new UserDirectReportsViewModel { UserID = -1, ParentID = -12, ModifiedBy = 1, ForceRollback = true }; // Act var response = _controller.Add(userReport, isMyProfile); // Assert Assert.IsTrue(response != null, "Response can't be null"); Assert.IsTrue(response.ResultCode != 0, "Direct Report created for invalid data."); }
public void Add_Success() { // Arrange var userReport = new UserDirectReportsViewModel { UserID = 21, ParentID = 12, ModifiedOn = DateTime.Now, ForceRollback = true }; // Act var response = _controller.Add(userReport, isMyProfile); // Assert Assert.IsTrue(response != null, "Response can't be null"); Assert.IsTrue(response.ResultCode == 0, "Direct Report could not be created."); }
/// <summary> /// To the view model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static UserDirectReportsViewModel ToViewModel(this UserDirectReportsModel entity) { if (entity == null) { return(null); } var model = new UserDirectReportsViewModel { IsSupervisor = entity.IsSupervisor, MappingID = entity.MappingID, Email = entity.Email, ParentID = entity.ParentID, ModifiedOn = entity.ModifiedOn, ForceRollback = entity.ForceRollback, UserID = entity.UserID, UserGUID = entity.UserGUID, ADFlag = entity.ADFlag, UserName = entity.UserName, FirstName = entity.FirstName, LastName = entity.LastName, MiddleName = entity.MiddleName, GenderID = entity.GenderID, Password = entity.Password, EffectiveToDate = entity.EffectiveToDate, Roles = entity.Roles, Credentials = entity.Credentials.ToModel(), LoginAttempts = entity.LoginAttempts, LoginCount = entity.LoginCount, LastLogin = entity.LastLogin, IPAddress = entity.IPAddress, SessionID = entity.SessionID, PrimaryEmail = entity.PrimaryEmail, EmailID = entity.EmailID, Gender = entity.Gender, ModifiedBy = entity.ModifiedBy, IsActive = entity.IsActive, HasSupervisor = entity.HasSupervisor }; return(model); }
public Response <UserDirectReportsViewModel> Add(UserDirectReportsViewModel userDetail, bool isMyProfile) { return(_userDirectReportsRepository.Add(userDetail, isMyProfile)); }