/// <summary> /// Gets the department registration view. /// </summary> /// <param name="deptInfo">The dept information.</param> /// <param name="message">The message.</param> /// <returns></returns> public IDepartmentView GetDepartmentRegistrationView(IDepartmentView deptInfo, string message) { var companyId = (int)this.session.GetSessionValue(SessionKey.CompanyId); var departmentsList = this.departmentRepository.GetAllMyDepartments(companyId); var viewModel = this.adminViewModelFactory.CreateDepartmentView(departmentsList, deptInfo, message); return(viewModel); }
/// <summary> /// Processes the department information. /// </summary> /// <param name="deptInfo">The dept information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">deptInfo</exception> public string ProcessDepartmentInfo(IDepartmentView deptInfo) { if (deptInfo == null) { throw new ArgumentNullException(nameof(deptInfo)); } var processingMessage = string.Empty; var isDataOkay = true; //Check that This Company Has not registered this Department Before var departmentData = this.departmentRepository.GetCompanyDepartmentByName(deptInfo.DepartmentName, deptInfo.CompanyId); if (departmentData != null) { processingMessage = Messages.DepartmentAlreadyExisted; isDataOkay = false; } // check if parentDepartment is setup for company before if (deptInfo.ParentDepartmentId.HasValue && (deptInfo.ParentDepartmentId.Value > 0) && isDataOkay) { var parentDepartmentData = this.departmentRepository.GetCompanyDepartmentById(deptInfo.ParentDepartmentId.Value, deptInfo.CompanyId); if (parentDepartmentData == null) { processingMessage = Messages.ParentDepartmentNotSetupText; isDataOkay = false; } } if (!isDataOkay) { return(processingMessage); } //Everything is Okay, Proceed to store var savedDataMessage = this.departmentRepository.SaveDepartmentInfo(deptInfo); return(savedDataMessage); }
/// <summary> /// Creates the updated department view. /// </summary> /// <param name="deptInfo">The dept information.</param> /// <param name="departmentCollection">The department collection.</param> /// <param name="processingMessage">The processing message.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">deptInfo</exception> /// <exception cref="ArgumentException">departmentCollection</exception> public IDepartmentView CreateUpdatedDepartmentView(IDepartmentView deptInfo, IList <IDepartment> departmentCollection, string processingMessage) { if (deptInfo == null) { throw new ArgumentNullException(nameof(deptInfo)); } if (departmentCollection == null) { throw new ArgumentException(nameof(departmentCollection)); } var departmentDDL = GetDropDownList.DepartmentListItems(departmentCollection, -1); deptInfo.ParentDepartmentDropDown = departmentDDL; deptInfo.ProcessingMessage = processingMessage; return(deptInfo); }
/// <summary> /// Saves the department information. /// </summary> /// <param name="deptInfo">The dept information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">deptInfo</exception> /// <exception cref="System.ArgumentNullException">deptInfo</exception> public string SaveDepartmentInfo(IDepartmentView deptInfo) { if (deptInfo == null) { throw new ArgumentNullException(nameof(deptInfo)); } var result = string.Empty; var newRecord = new Department { Description = deptInfo.Description, DepartmentId = deptInfo.DepartmentId, IsActive = deptInfo.IsActive, DepartmentName = deptInfo.DepartmentName, ParentDepartmentID = deptInfo.ParentDepartmentId, CompanyId = deptInfo.CompanyId, DateCreated = deptInfo.DateCreated }; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { dbContext.Departments.Add(newRecord); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("SaveRegistrationInfo - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Updates the department information. /// </summary> /// <param name="deptInfo">The dept information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">deptInfo</exception> /// <exception cref="ApplicationException">departmentData</exception> public string UpdateDepartmentInfo(IDepartmentView deptInfo) { if (deptInfo == null) { throw new ArgumentNullException(nameof(deptInfo)); } var result = string.Empty; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { var departmentData = dbContext.Departments.SingleOrDefault(m => m.DepartmentId.Equals(deptInfo.DepartmentId)); if (departmentData == null) { throw new ApplicationException(nameof(departmentData)); } departmentData.Description = deptInfo.Description; departmentData.DepartmentName = deptInfo.DepartmentName; departmentData.ParentDepartmentID = deptInfo.ParentDepartmentId; dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("Update Department Information - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Creates the department view. /// </summary> /// <param name="departmentCollection">The department collection.</param> /// <param name="companyCollection">The company collection.</param> /// <param name="deptInfo">The dept information.</param> /// <param name="message">The message.</param> /// <returns></returns> public IDepartmentView CreateDepartmentView(IList <IDepartment> departmentCollection, IDepartmentView deptInfo, string message) { var departmentDDL = GetDropDownList.DepartmentListItems(departmentCollection, deptInfo.ParentDepartmentId); var view = deptInfo; view.ProcessingMessage = message; view.ParentDepartmentDropDown = departmentDDL; return(view); }
public DepartmentDataCollector(IDepartmentView itsView) { _ItsView = itsView; }
public DepartmentDataBinder(IDepartmentView itsView, Account loginUser) : base(loginUser) { _ItsView = itsView; }
public UpdateDepartmentPresenter(IDepartmentView itsView, Account loginUser) { _LoginUser = loginUser; _ItsView = itsView; AttachViewEvent(); }
/// <summary> /// Конструктор. /// </summary> /// <param name="View">Форма для вывода.</param> /// <param name="CurrentDepartment">Подразделение.</param> public DepartmentPresenter(IDepartmentView View, Department CurrentDepartment) { this.view = View; currentDepartment = CurrentDepartment; }
public DepartmentVaildater(IDepartmentView itsView) { _ItsView = itsView; }
public DepartmentIniter(IDepartmentView itsView) { _ItsView = itsView; }