/// <summary> /// To get all M3Users /// </summary> /// <returns></returns> public List <AllUsersViewModel> GetAllM3Users() { BusinessResponse businessResponse = new BusinessResponse(); try { List <AllUsers> users = _clientUserRepository.GetAllM3Users(); List <AllUsersViewModel> allUsers = new List <AllUsersViewModel>(); if (users != null && users.Count > 0) { foreach (AllUsers user in users) { allUsers.Add(BusinessMapper.AllUsersBusinessToAllUsesrViewModel(user)); } } return(allUsers); } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); businessResponse.IsSuccess = false; businessResponse.IsExceptionOccured = true; businessResponse.Messages.Add(new MessageDTO() { Message = BusinessConstants.M3USERS_GET_FAIL, MessageType = Infrastructure.Enums.MessageType.Error }); return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { try { var dao = BusinessMapper.GetDaoByEntity(BusinessMapper.eEntities.IdentAtencion); IdentAtencionDTO entity = (DTO.IdentAtencionDTO)CRUDHelper.Read(Convert.ToInt32(pnlControls.Attributes["RecId"]), dao); FormsHelper.FillEntity(tblControls, entity); if (!entity.Estado && dao.ExisteAvisoEnVigencia(entity.IdentifIdentAte)) { throw new Exception("No se puede deshabilitar, ya que se encuentra en uso por un aviso vigente."); } CRUDHelper.Update(entity, BusinessMapper.GetDaoByEntity(BusinessMapper.eEntities.IdentAtencion)); pnlControls.Visible = false; RefreshGrid(gv); } catch (Exception ex) { FormsHelper.MsgError(lblError, ex); } }
protected void Page_Load(object sender, EventArgs e) { DAO = BusinessMapper.GetDaoByEntity(BusinessMapper.eEntities.PiezasArte); if (!Page.IsPostBack && !Page.IsCallback) { trMsg.Visible = false; trAbm.Visible = false; gvABM.SettingsBehavior.AllowSelectByRowClick = true; gvABM.SettingsBehavior.AllowSelectSingleRowOnly = true; FormsHelper.BuildColumnsByEntity(BusinessMapper.eEntities.PiezasArte, gv); FormsHelper.InicializarPropsGrilla(gv); } ucIdentifAnun.Inicializar(BusinessMapper.eEntities.AnunInternos); ucIdentifTipoPieza.Inicializar(BusinessMapper.eEntities.TipoPieza); ucIdentifSKU.Inicializar(BusinessMapper.eEntities.SKU); ucIdentifTipoPieza.ComboBox.AutoPostBack = true; ucIdentifTipoPieza.ComboBox.SelectedIndexChanged += new EventHandler(TipoPieza_SelectedIndexChanged); gvABM.KeyFieldName = "RecId"; ASPxMenu1.ItemClick += new DevExpress.Web.ASPxMenu.MenuItemEventHandler(ASPxMenu1_ItemClick); rbTipoProd.AutoPostBack = true; rbTipoProd.SelectedIndexChanged += new EventHandler(rbTipoProd_SelectedIndexChanged); RefreshGrid(gv); RefreshAbmGrid(gvABM); lblError.Text = string.Empty; lblErrorProducto.Text = string.Empty; }
/// <summary> /// Get Completed Checklists For A Selected Date Range /// </summary> /// <param name="checklistDataRequest"></param> /// <returns></returns> public string GetCompletedChecklistsForADateRange(ChecklistDataRequestViewModel checklistDataRequest) { try { ChecklistDataRequest request = BusinessMapper.MappingOpenChecklistViewModelToBusinessModel(checklistDataRequest); List <ChecklistDataResponse> checklistDataList = _pendingChecklistRepository.GetChecklistsForADateRange(request); ChecklistDataResponse[] checklistDataArray = checklistDataList.ToArray(); List <IDictionary <string, object> > pivotArray = checklistDataArray.ToPivotArray(item => item.EffectiveDate, item => item.RowSelector, items => items.Any() ? items.First().Answer : new AnswerResponse() { SubmittedResponse = "--" }); foreach (IDictionary <string, object> ele in pivotArray) { ChecklistDataResponse result = checklistDataList.First(c => c.RowSelector == (ele.ContainsKey("RowSelector") ? (string)ele["RowSelector"] : string.Empty)); if (result != null) { ele.Add("ChecklistName", result.ChecklistName); ele.Add("QuestionText", result.QuestionText); } } String json = JsonConvert.SerializeObject(pivotArray, new KeyValuePairConverter()); return(json); } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); return(null); } }
public IEnumerable <ProductDto> Invoke(BusinessKeyDto input) { _logger.Log($"Starting {GetType().FullName}"); _logger.Log("Input model received: ", input, LogType.Debug); var businessKey = BusinessMapper.ToBusinessKey(input); var business = _businessRepository.Find(businessKey); if (business == null) { var error = new BusinessDoesNotExists(businessKey); _logger.Log(error.Message, businessKey, LogType.Error); throw error; } var products = _productRepository.FindByBusiness(businessKey); var output = new List <ProductDto>(products.Select(product => new ProductDto() { BusinessCode = business.Code, ProductCode = product.Code, ProductName = product.Name, ProductDescription = product.Description })); _logger.Log("Output model to return: ", output, LogType.Debug); return(output); }
public async Task <LoginResult> Login(LoginModel login) { var result = new LoginResult(); var user = await _userManager.Users.Include(u => u.Person) .FirstOrDefaultAsync(x => x.UserName == login.Username.ToLower()); if (user == null) { result.Fail("Username/password incorrect."); return(result); } var signInResult = await _signInManager.CheckPasswordSignInAsync(user, login.Password, false); if (!signInResult.Succeeded) { result.Fail("Username/password incorrect."); } else if (!user.Enabled) { result.Fail("Your account has been disabled. Please try again later."); } else { result.Success(BusinessMapper.Map <UserModel>(user)); } return(result); }
/// <summary> /// To save the M3 user data /// </summary> /// <param name="m3User"></param> /// <returns></returns> public ValidationViewModel SaveM3User(M3UserViewModel m3User) { ValidationViewModel validationViewModel = new ValidationViewModel(); try { UserLoginDTO userLogin = BusinessMapper.MappingM3UserViewModelToBusinessModel(m3User); validationViewModel.Success = _allUserRepository.SaveUser(userLogin); if (validationViewModel.Success && !m3User.IsUserExist) { string isDefaultEmailEnabled = Helper.GetConfigurationKey(BusinessConstants.USE_DEFAULT_EMAIL_FOR_M3PACT_USER); string email = userLogin.Email; string userFullName = userLogin.FirstName + " " + userLogin.LastName; if (isDefaultEmailEnabled != null) { email = bool.Parse(isDefaultEmailEnabled) == true?Helper.GetConfigurationKey(BusinessConstants.MAIL_FROM) : userLogin.Email; } validationViewModel.Success = SendLoginSuccessMail(email, userFullName); } } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); validationViewModel.Success = false; validationViewModel.ErrorMessages.Add(BusinessConstants.ERROR_SAVE_DETAILS); } return(validationViewModel); }
public async Task Create(AcademicYearModel academicYearModel) { var academicYear = BusinessMapper.Map <AcademicYear>(academicYearModel); _academicYearRepository.Create(academicYear); await _academicYearRepository.SaveChanges(); }
void gvABM_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { e.Cancel = true; CRUDHelper.Delete(Convert.ToInt32(e.Keys[0]), BusinessMapper.GetDaoByEntity(BusinessMapper.eEntities.FrecuenciaDet)); RefreshAbmGrid(gvABM); }
protected void cbIdentifIdentAte_ItemsRequestedByFilterCondition(object source, DevExpress.Web.ASPxEditors.ListEditItemsRequestedByFilterConditionEventArgs e) { ASPxComboBox comboBox = (ASPxComboBox)source; var daoIdentAtencion = BusinessMapper.GetDaoByEntity(BusinessMapper.eEntities.IdentAtencion); comboBox.DataSource = daoIdentAtencion.FindPaginado(e.Filter, (e.BeginIndex + 1), (e.EndIndex + 1)); comboBox.DataBind(); }
public OrderDTO GetOrderByOrderNumberV2(int orderId) { var o = _orderBroker.GetOrderByOrderNumber(orderId); var ops = o.OrderProduct.Where(x => x.OrderId == orderId).Select(x => x).ToList(); var products = _productBroker.GetAllProductsByIdV2(ops); var order = OrderMapper.OrderToOrderDTOV2(o, ops, products); order.Business = BusinessMapper.BusinessToBusinessDTO(_orderBroker.GetBusinessById(o.BusinessOrder.Where(x => x.OrderId == o.OrderId).Select(x => x.BusinessId).Single())); return(order); }
public async Task <RoleModel> GetRoleById(Guid roleId) { var role = await _roleManager.FindByIdAsync(roleId.ToString()); if (role == null) { throw new NotFoundException("Role not found."); } return(BusinessMapper.Map <RoleModel>(role)); }
public async Task <AttendanceMarkModel> Get(Guid studentId, Guid attendanceWeekId, Guid periodId) { var attendanceMark = await _attendanceMarkRepository.Get(studentId, attendanceWeekId, periodId); if (attendanceMark == null) { return(NoMark(studentId, attendanceWeekId, periodId)); } return(BusinessMapper.Map <AttendanceMarkModel>(attendanceMark)); }
public async Task <AttendanceWeekModel> GetByDate(DateTime date, bool throwIfNotFound = true) { var week = await _attendanceWeekRepository.GetByDate(date); if (week == null && throwIfNotFound) { throw new NotFoundException("Attendance week not found."); } return(BusinessMapper.Map <AttendanceWeekModel>(week)); }
public async Task <AttendanceWeekModel> GetById(Guid attendanceWeekId) { var attendanceWeek = await _attendanceWeekRepository.GetById(attendanceWeekId); if (attendanceWeek == null) { throw new NotFoundException("Attendance week not found."); } return(BusinessMapper.Map <AttendanceWeekModel>(attendanceWeek)); }
public async Task <StaffMemberModel> GetByUserId(Guid userId, bool throwIfNotFound = true) { var staffMember = await _staffMemberRepository.GetByUserId(userId); if (staffMember == null && throwIfNotFound) { throw new NotFoundException("Staff member not found."); } return(BusinessMapper.Map <StaffMemberModel>(staffMember)); }
public async Task <AttendancePeriodModel> GetById(Guid periodId) { var period = await _periodRepository.GetById(periodId); if (period == null) { throw new NotFoundException("Period not found."); } return(BusinessMapper.Map <AttendancePeriodModel>(period)); }
public async Task <PersonModel> GetByUserId(Guid userId, bool throwIfNotFound = true) { var person = await _personRepository.GetByUserId(userId); if (person == null && throwIfNotFound) { throw new NotFoundException("Person not found."); } return(BusinessMapper.Map <PersonModel>(person)); }
public async Task <StudentModel> GetById(Guid studentId) { var student = await _studentRepository.GetById(studentId); if (student == null) { throw new NotFoundException("Student not found."); } return(BusinessMapper.Map <StudentModel>(student)); }
public async Task <StudentModel> GetByPersonId(Guid personId, bool throwIfNotFound = true) { var student = await _studentRepository.GetByPersonId(personId); if (student == null && throwIfNotFound) { throw new NotFoundException("Student not found."); } return(BusinessMapper.Map <StudentModel>(student)); }
public async Task <DirectoryModel> GetById(Guid directoryId) { var directory = await _directoryRepository.GetById(directoryId); if (directory == null) { throw new NotFoundException("Directory not found."); } return(BusinessMapper.Map <DirectoryModel>(directory)); }
public async Task <LogNoteModel> GetById(Guid logNoteId) { var logNote = await _logNoteRepository.GetById(logNoteId); if (logNote == null) { throw new NotFoundException("Log note not found."); } return(BusinessMapper.Map <LogNoteModel>(logNote)); }
public async Task <DocumentModel> GetDocumentById(Guid documentId) { var document = await _documentRepository.GetById(documentId); if (document == null) { throw new NotFoundException("Document not found."); } return(BusinessMapper.Map <DocumentModel>(document)); }
public async Task <TaskModel> GetById(Guid taskId) { var task = await _taskRepository.GetById(taskId); if (task == null) { throw new NotFoundException("Task not found."); } return(BusinessMapper.Map <TaskModel>(task)); }
public async Task <AcademicYearModel> GetCurrent() { var acadYear = await _academicYearRepository.GetCurrent(); if (acadYear == null) { throw new NotFoundException("Current academic year not defined."); } return(BusinessMapper.Map <AcademicYearModel>(acadYear)); }
public List <BusinessDTO> GetBusinesses(string postalCode) { var b = _orderBroker.GetBusinessesByPostal(postalCode); List <BusinessDTO> businesses = new List <BusinessDTO>(); foreach (var business in b) { businesses.Add(BusinessMapper.BusinessToBusinessDTO(business)); } return(businesses); }
/// <summary> /// to save a question through the repository layer call /// </summary> /// <param name="question"></param> /// <returns>asynchronous a business Question</returns> public async Task <Question> UpdateQuestion(CheckListItemViewModel checkListItemViewModel) { try { return(await _checkListRepository.UpdateQuestion(BusinessMapper.MappingChecklistItemViewModelToBusinessModel(checkListItemViewModel))); } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); return(null); } }
protected void cbIdentifIdentAte_ItemRequestedByValue(object source, DevExpress.Web.ASPxEditors.ListEditItemRequestedByValueEventArgs e) { if (e.Value == null || Convert.ToString(e.Value) == string.Empty) { return; } ASPxComboBox comboBox = (ASPxComboBox)source; var daoIdentAtencion = BusinessMapper.GetDaoByEntity(BusinessMapper.eEntities.IdentAtencion); comboBox.DataSource = daoIdentAtencion.FindValue(Convert.ToString(e.Value)); comboBox.DataBind(); }
/// <summary> /// Business method to call repository To get the attributes /// </summary> /// <returns></returns> public List <AttributesViewModel> GetAttributesForConfig() { try { List <AttributesBusinessModel> attributes = _configurationsRepository.GetAttributesForConfig(); return(BusinessMapper.AttributesBusinessModelToAttributesViewModel(attributes)); } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); return(null); } }
/// <summary> /// to get tasks for a user and clients for tasks /// </summary> /// <returns></returns> public List <TodoViewModel> GetClientsForAllToDoTasks() { try { List <TodoBusinessModel> todoBusinessModels = _toDoRepository.GetClientsForAllToDoTasks(); return(BusinessMapper.MappingTodoBusinessToViewModel(todoBusinessModels)); } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); return(null); } }
internal void Inicializar(BusinessMapper.eEntities entityName, string where) { EntityName = entityName.ToString(); Inicializar(MapInfo.DAOHandler.ReadAll(where), MapInfo.EntityTextField, MapInfo.EntityValueField); }
internal void Inicializar(BusinessMapper.eEntities entityName, bool autoPostBack) { EntityName = entityName.ToString(); Inicializar(MapInfo.DAOHandler.ReadAll(""), MapInfo.EntityTextField, MapInfo.EntityValueField); cmbEntidad.AutoPostBack = autoPostBack; }
public void Inicializar(BusinessMapper.eEntities entidad) { ObjetoDTO = DTOHelper.InstanciarObjetoPorNombreDeTabla(entidad.ToString()); Entidad = entidad; dao = BusinessMapper.GetDaoByEntity(entidad); this.create = Create; this.update = Update; this.ReadMethod = Read; this.delete = Delete; List<ABMControl> controls = GetControlsByEntity(entidad); BuildControls(controls.ToArray()); }
private List<ABMControl> GetControlsByEntity(BusinessMapper.eEntities entidad) { List<ABMControl> controls = new List<ABMControl>(); if (BusinessMapper.AbmConfigXmlPath == null || BusinessMapper.AbmConfigXmlPath == string.Empty) throw new Exception("Path del archivo AbmConfig.xml sin definir."); XmlDocument xDoc = new XmlDocument(); xDoc.Load(BusinessMapper.AbmConfigXmlPath); foreach (XmlNode nodeControl in xDoc.SelectSingleNode( "Entities/Entity[@EntityName='" + entidad.ToString() + "']").ChildNodes) { if (nodeControl.Attributes["ControlType"].Value == "ComboBox") { controls.Add(new ABMControl() { ComboBox = (ucComboBox)Page.LoadControl("~/Controls/ucComboBox.ascx"), Title = nodeControl.Attributes["Title"].Value, FieldName = nodeControl.Attributes["FieldName"].Value, EntityName = nodeControl.Attributes["FieldName"].Value }); controls[controls.Count - 1].ComboBox.Inicializar(nodeControl.Attributes["EntityName"].Value); } else if (nodeControl.Attributes["ControlType"].Value == "TextBox") { controls.Add(new ABMControl() { TextBox = new ASPxTextBox(), Title = nodeControl.Attributes["Title"].Value, FieldName = nodeControl.Attributes["FieldName"].Value, }); } else if (nodeControl.Attributes["ControlType"].Value == "SpinEdit") { controls.Add(new ABMControl() { Control = new ASPxSpinEdit(), Title = nodeControl.Attributes["Title"].Value, FieldName = nodeControl.Attributes["FieldName"].Value, }); } else if (nodeControl.Attributes["ControlType"].Value == "CheckBox") { controls.Add(new ABMControl() { Control = new ASPxCheckBox(), Title = nodeControl.Attributes["Title"].Value, FieldName = nodeControl.Attributes["FieldName"].Value, }); } else if (nodeControl.Attributes["ControlType"].Value == "RadioButtonList") { controls.Add(new ABMControl() { Control = new ASPxRadioButtonList(), Title = nodeControl.Attributes["Title"].Value, FieldName = nodeControl.Attributes["FieldName"].Value }); controls[controls.Count - 1].Items = new List<Item>(); foreach (XmlNode nodeItem in nodeControl.SelectNodes("Items/Item")) { controls[controls.Count - 1].Items.Add( new Item(nodeItem.Attributes["Value"].Value, nodeItem.Attributes["Name"].Value)); } } } return controls; }
internal static void BuildColumnsByEntity(BusinessMapper.eEntities entidad, ASPxGridView gv) { if (BusinessMapper.AbmConfigXmlPath == null || BusinessMapper.AbmConfigXmlPath == string.Empty) throw new Exception("Path del archivo AbmConfig.xml sin definir."); XmlDocument xDoc = new XmlDocument(); xDoc.Load(BusinessMapper.AbmConfigXmlPath); gv.Columns.Clear(); if (xDoc.SelectSingleNode( "Entities/Entity[@EntityName='" + entidad.ToString() + "']") == null) throw new AbmConfigXMLException("No existe la configuración de mapeo para la entidad: " + entidad.ToString()); foreach (XmlNode nodeControl in xDoc.SelectSingleNode( "Entities/Entity[@EntityName='" + entidad.ToString() + "']").ChildNodes) { if (nodeControl.Attributes["ControlType"].Value == "ComboBox") { GridViewDataComboBoxColumn gvc = new GridViewDataComboBoxColumn(); gvc.Name = nodeControl.Attributes["FieldName"].Value; gvc.Caption = nodeControl.Attributes["Title"].Value; gvc.FieldName = nodeControl.Attributes["FieldName"].Value; var mapInfo = BusinessMapper.GetMapInfo(nodeControl.Attributes["EntityName"].Value); gvc.PropertiesComboBox.TextField = mapInfo.EntityTextField; gvc.PropertiesComboBox.ValueField = mapInfo.EntityValueField; gvc.PropertiesComboBox.DataSource = mapInfo.DAOHandler.ReadAll(""); gv.Columns.Add(gvc); } else if (nodeControl.Attributes["ControlType"].Value == "RadioButtonList") { GridViewDataComboBoxColumn gvc = new GridViewDataComboBoxColumn(); gvc.Name = nodeControl.Attributes["FieldName"].Value; gvc.Caption = nodeControl.Attributes["Title"].Value; gvc.FieldName = nodeControl.Attributes["FieldName"].Value; gvc.PropertiesComboBox.Items.Clear(); foreach (XmlNode item in nodeControl.ChildNodes[0].ChildNodes) { gvc.PropertiesComboBox.Items.Add(item.Attributes["Name"].Value, item.Attributes["Value"].Value); } gv.Columns.Add(gvc); } else if (nodeControl.Attributes["ControlType"].Value == "TextBox" || nodeControl.Attributes["ControlType"].Value == "SpinEdit" || nodeControl.Attributes["ControlType"].Value == "TimeEdit") { GridViewDataTextColumn gvc = new GridViewDataTextColumn(); gvc.Name = nodeControl.Attributes["FieldName"].Value; gvc.Caption = nodeControl.Attributes["Title"].Value; gvc.FieldName = nodeControl.Attributes["FieldName"].Value; gv.Columns.Add(gvc); } else if (nodeControl.Attributes["ControlType"].Value == "DateEdit") { GridViewDataDateColumn gvc = new GridViewDataDateColumn(); gvc.Name = nodeControl.Attributes["FieldName"].Value; gvc.Caption = nodeControl.Attributes["Title"].Value; gvc.FieldName = nodeControl.Attributes["FieldName"].Value; gv.Columns.Add(gvc); } else if (nodeControl.Attributes["ControlType"].Value == "CheckBox") { GridViewDataCheckColumn gvc = new GridViewDataCheckColumn(); gvc.Name = nodeControl.Attributes["FieldName"].Value; gvc.Caption = nodeControl.Attributes["Title"].Value; gvc.FieldName = nodeControl.Attributes["FieldName"].Value; gv.Columns.Add(gvc); } } }
internal static GridViewDataComboBoxColumn BuildComboColumn(string caption, string fieldName, BusinessMapper.eEntities entity) { GridViewDataComboBoxColumn gvc = new GridViewDataComboBoxColumn(); gvc.Name = fieldName; gvc.Caption = caption; gvc.FieldName = fieldName; var mapInfo = BusinessMapper.GetMapInfo(entity.ToString()); gvc.PropertiesComboBox.TextField = mapInfo.EntityTextField; gvc.PropertiesComboBox.ValueField = mapInfo.EntityValueField; gvc.PropertiesComboBox.DataSource = mapInfo.DAOHandler.ReadAll(""); return gvc; }