Пример #1
0
        public List <Companies> GetAllCompanies()
        {
            List <Companies> companiesList = null;

            companiesList = _companiesRepository.GetAllCompanies();
            companiesList = companiesList != null?companiesList.OrderBy(c => c.Name).ToList() : null;

            return(companiesList);
        }
Пример #2
0
        public async Task <JsonResult> SyncCompanies()
        {
            var knownCompanies = await _companiesRepository.GetAllCompanies();

            var radarioCompanies = mf.CompanyManager.GetAllCompanies();
            var updateCount      = 0;
            var insertCount      = 0;

            foreach (var radarioCompany in radarioCompanies)
            {
                var entity = knownCompanies.SingleOrDefault(x => x.CompanyId == radarioCompany.Id);
                if (entity == null)
                {
                    entity = new Company()
                    {
                        CompanyId      = radarioCompany.Id,
                        CompanyTitle   = radarioCompany.Title,
                        PublicGuid     = Guid.NewGuid(),
                        FullAccessGuid = Guid.NewGuid()
                    };
                    await _companiesRepository.Insert(entity);

                    insertCount++;
                }
                else
                {
                    if (!radarioCompany.Title.Equals(entity.CompanyTitle,
                                                     StringComparison.InvariantCultureIgnoreCase))
                    {
                        entity.CompanyTitle = radarioCompany.Title;
                        await _companiesRepository.Update(entity);

                        updateCount++;
                    }
                }
            }
            return(Json(new {
                Updated = updateCount,
                CreatedNew = insertCount
            }, JsonSerializerSettings));
        }
 public List <Company> GetAllCompaniesList()
 {
     return(_companiesRepository.GetAllCompanies());
 }
        /// <summary>
        /// To validate Each row and then returns error rows with the corresponding error if erorr exists
        /// </summary>
        /// <param name="importOtherExpenseList">List of datas from excel</param>
        /// <param name="flag"> if flag=true then validates and inserts else, only validates </param>
        /// <returns></returns>
        public List <ImportOtherExpenses> InsertValidateExpenseData(List <ImportOtherExpenses> importOtherExpenseList, bool flag)
        {
            List <ChartOfAccounts> chartOfAccountsList = _chartOfAccountsRepository.GetAllChartOfAccounts("OE");
            List <Companies>       companiesList       = _companiesRepository.GetAllCompanies();
            List <Employee>        employeeList        = _employeeRepository.GetAllEmployees(null);

            try
            {
                List <ImportOtherExpenses> removedDataList = new List <ImportOtherExpenses>();
                string[] AccountList   = (from i in chartOfAccountsList where i.Type == "OE" select i.Code).ToArray();
                string[] CompanyNames  = (from i in companiesList select i.Name).ToArray();
                string[] EmployeeCodes = (from i in employeeList select i.Code).ToArray();
                //string[] EmployeeNames  = (from i in employeeList select i.Name).ToArray();
                foreach (ImportOtherExpenses anImportOtherExpense in importOtherExpenseList)
                {
                    if (AccountList.Contains(anImportOtherExpense.AccountCode))
                    {
                        if (CompanyNames.Contains(anImportOtherExpense.Company))
                        {
                            if (/*(anImportOtherExpense.EmpName.Equals("-") || anImportOtherExpense.EmpName.Equals("") || EmployeeNames.Contains(anImportOtherExpense.EmpName)) &&*/ (anImportOtherExpense.EmpCode.Equals("-") || anImportOtherExpense.EmpCode.Equals("") || EmployeeCodes.Contains(anImportOtherExpense.EmpCode)))
                            {
                                ImportOtherExpenses importExpenseReturn = new ImportOtherExpenses();
                                try
                                {
                                    importExpenseReturn = ModifyRow(anImportOtherExpense, companiesList, employeeList);
                                }
                                catch (Exception ex)
                                {
                                    if (ex.Message.Equals("Sequence contains no elements"))
                                    {
                                        anImportOtherExpense.Error       = "Invalid Employee";
                                        anImportOtherExpense.ExpenseDate = DateTime.Parse(anImportOtherExpense.ExpenseDate).ToString(settings.dateformat);
                                        removedDataList.Add(anImportOtherExpense);
                                    }
                                    else
                                    {
                                        throw ex;
                                    }
                                }
                                if (flag == true)
                                {
                                    InsertInToOtherExpenses(importExpenseReturn);
                                }
                            }
                            else
                            {
                                anImportOtherExpense.Error       = "Invalid Employee";
                                anImportOtherExpense.ExpenseDate = DateTime.Parse(anImportOtherExpense.ExpenseDate).ToString(settings.dateformat);
                                removedDataList.Add(anImportOtherExpense);
                            }
                        }
                        else
                        {
                            anImportOtherExpense.Error       = "Invalid Company";
                            anImportOtherExpense.ExpenseDate = DateTime.Parse(anImportOtherExpense.ExpenseDate).ToString(settings.dateformat);
                            removedDataList.Add(anImportOtherExpense);
                        }
                    }
                    else
                    {
                        anImportOtherExpense.Error       = "Invalid Account Code";
                        anImportOtherExpense.ExpenseDate = DateTime.Parse(anImportOtherExpense.ExpenseDate).ToString(settings.dateformat);
                        removedDataList.Add(anImportOtherExpense);
                    }
                }

                return(removedDataList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public async Task <IList <Company> > ExecuteAsync()
 {
     return(await _companiesRepository.GetAllCompanies());
 }