public IEnumerable <NewUsersIn30DaysServiceModel> GetNewUsersIn30Days() { var entity = _unitOfWork.AddRepository <NewUsersIn30Days>() .GetRepository <NewUsersIn30Days>() .FromSQL(new NewUsersIn30Days().GetQuery()); var temp = _mapper.Map <List <NewUsersIn30DaysServiceModel> >(entity); var serviceModel = new List <NewUsersIn30DaysServiceModel>(); int index = 0; for (int i = 0; i <= 29; i++) { if (temp.Any(x => x.Day == i)) { serviceModel.Add(new NewUsersIn30DaysServiceModel { Day = i, UserCount = temp[index].UserCount }); index++; } else { serviceModel.Add(new NewUsersIn30DaysServiceModel { Day = i, UserCount = 0 }); } } return(serviceModel); }
public int GetCurrencyId(string currency) { return(_unitOfWork.AddRepository <CurrencyEntityModel>() .GetRepository <CurrencyEntityModel>() .Get(x => x.Name == currency) .FirstOrDefault() .Id); }
public int AddTransaction(FinancialTransactionServiceModel transaction) { var entity = _mapper.Map <TransactionEntityModel>(transaction); _dateService.SetDateCreatedNow(ref entity); _unitOfWork.AddRepository <TransactionEntityModel>() .GetRepository <TransactionEntityModel>() .AddItem(entity); return(entity.Id); }
public FileDownloadServiceModel GetFileById(int fileId, bool includeFileData = false) { string include = includeFileData ? "File" : ""; var file = _unitOfWork.AddRepository <FileDescriptorEntityModel>() .GetRepository <FileDescriptorEntityModel>() .Get(x => x.Id == fileId, null, include) .FirstOrDefault(); var serviceFile = _mapper.Map <FileDownloadServiceModel>(file); return(serviceFile); }
public int CreateTicket(TicketServiceModel ticket) { var ticketRepo = _unitOfWork.AddRepository <TicketEntityModel>().GetRepository <TicketEntityModel>(); var entity = _mapper.Map <TicketEntityModel>(ticket); _dateService.SetDateCreatedNow(ref entity); entity.TicketType = null; entity.TicketStatus = null; ticketRepo.AddItem(entity); _unitOfWork.Save(); return(entity.Id); }
public int CreateWallet(WalletServiceModel wallet) { _unitOfWork.AddRepository <WalletEntityModel>(); var walletEntity = _mapper.Map <WalletEntityModel>(wallet); walletEntity.RegistrantId = wallet.RegistrantId; _dateService.SetDateCreatedNow(ref walletEntity); _unitOfWork.GetRepository <WalletEntityModel>().AddItem(walletEntity); _unitOfWork.Save(); return(walletEntity.Id); }
public int CreateAccount(AccountServiceModel account) { _unitOfWork.AddRepository <AccountEntityModel>(); var accountEntity = _mapper.Map <AccountEntityModel>(account); _dateService.SetDateCreatedNow(ref accountEntity); _unitOfWork.GetRepository <AccountEntityModel>().AddItem(accountEntity); _unitOfWork.Save(); return(accountEntity.Id); }
public int CreateRegistrant(RegistrantServiceModel registrant) { _unitOfWork.AddRepository <RegistrantEntityModel>(); var registrantEntity = _mapper.Map <RegistrantEntityModel>(registrant); _dateService.SetDateCreatedNow(ref registrantEntity); _unitOfWork.GetRepository <RegistrantEntityModel>().AddItem(registrantEntity); _unitOfWork.Save(); return(registrantEntity.Id); }
public IEnumerable <CountryServiceModel> GetCountries() { _unitOfWork.AddRepository <CountryEntityModel>(); var countriesRepoModel = _unitOfWork.GetRepository <CountryEntityModel>().Get().ToList(); var countriesServiceModel = _mapper.Map <List <CountryServiceModel> >(countriesRepoModel); return(countriesServiceModel); }
public bool DeleteUser(int id) { _unitOfWork.AddRepository <UserEntityModel>(); var userRepo = _unitOfWork.GetRepository <UserEntityModel>(); var userEntity = userRepo.Get(user => user.Id == id, null, "Registrant").FirstOrDefault(); if (userEntity.Registrant != null) { return(false); } userRepo.Delete(id); _unitOfWork.Save(); return(true); }
public IEnumerable <AllWalletsWithSums> GetAllWalletsWithSums(string orderBy, AllWalletsWithSumsFiltersServiceModel filters) { var repo = _unitOfWork.AddRepository <AllWalletsWithSums>().GetRepository <AllWalletsWithSums>(); var allWalletsWithSums = new List <AllWalletsWithSums>(); var rawSql = new AllWalletsWithSums().GetQuery(); if (filters != null) { IEnumerable <AllWalletsWithSums> query = new List <AllWalletsWithSums>(); if (filters.Countries.Any()) { query = repo.FromSQL(rawSql, x => filters.Countries.Any(y => filters.Countries.Contains(x.ClientCountry))); } if (!query.Any()) { query = repo.FromSQL(rawSql); } if (DateTime.TryParseExact(filters.RegisteredFrom, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateFrom) && DateTime.TryParseExact(filters.RegisteredTo, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTo)) { query = query.Where(x => x.Date >= dateFrom && x.Date <= dateTo); } allWalletsWithSums = query.ToList(); } else { allWalletsWithSums = repo.FromSQL(rawSql).ToList(); } switch (orderBy) { case "Id": allWalletsWithSums = allWalletsWithSums.OrderBy(y => y.Id).ToList(); break; case "Id_desc": allWalletsWithSums = allWalletsWithSums.OrderByDescending(y => y.Id).ToList(); break; case "ClientName": allWalletsWithSums = allWalletsWithSums.OrderBy(y => y.ClientName).ToList(); break; case "ClientName_desc": allWalletsWithSums = allWalletsWithSums.OrderByDescending(y => y.ClientName).ToList(); break; case "ClientCountry": allWalletsWithSums = allWalletsWithSums.OrderBy(y => y.ClientCountry).ToList(); break; case "ClientCountry_desc": allWalletsWithSums = allWalletsWithSums.OrderByDescending(y => y.ClientCountry).ToList(); break; case "Balance": allWalletsWithSums = allWalletsWithSums.OrderBy(y => y.Balance).ToList(); break; case "Balance_desc": allWalletsWithSums = allWalletsWithSums.OrderByDescending(y => y.Balance).ToList(); break; case "Currency": allWalletsWithSums = allWalletsWithSums.OrderBy(y => y.Currency).ToList(); break; case "Currency_desc": allWalletsWithSums = allWalletsWithSums.OrderByDescending(y => y.Currency).ToList(); break; default: allWalletsWithSums = allWalletsWithSums.OrderBy(y => y.Id).ToList(); break; } return(allWalletsWithSums); }