public ActionResult GetTransactionsBySearchNameFilters(string bankAccountId, string name, string fromDate, string toDate, int?selectedItemsForPage, int?selectedFilterId, int page = 1) { if (!String.IsNullOrEmpty(bankAccountId) && !String.IsNullOrEmpty(name)) { var bankAccount = _readBankAccount.GetBankAccountById(bankAccountId); var binder = new ToTransactionListViewModel(); var currencyLogic = new CurrencyLogic(); var filterLogic = new FiltersLogic(); var filterName = ""; var filterValue = ""; var fromDateConverted = filterLogic.GetDateTimeByDateStringWithDots(fromDate); var toDateConverted = filterLogic.GetEndDateTimeDateStringWithDots(toDate); filterLogic.GetFilterNameFilterValueById(selectedFilterId, out filterName, out filterValue); var itemsForPage = filterLogic.GetItemsForPageById(selectedItemsForPage); var transactions = _readTransaction.GetSearchTransactionsByFilters(bankAccountId, fromDateConverted, toDateConverted, filterName, filterValue, name); var viewModelTransactions = binder.GetTransactions(transactions, currencyLogic.GetCurrencyIconById(bankAccount.Currency)).ToPagedList(page, itemsForPage); return(PartialView("TransactionList", viewModelTransactions)); } else { return(new JsonResult { Data = "Wystąpił błąd podczas operacji.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public User AddUser(string name, string email, string password, string token, string phone) { string hashPassword = HashPassword(password, password); var roleLogic = new RoleLogic(); var newUser = new User(); var newTeam = new Team(); var currencyLogic = new CurrencyLogic(); var newUserTeamLink = new UserTeamLink(); byte[] time = BitConverter.GetBytes(DateTime.UtcNow.ToBinary()); byte[] key = Guid.NewGuid().ToByteArray(); string newToken = Convert.ToBase64String(time.Concat(key).ToArray()); var defaultUserRole = roleLogic.GetRole(Roles.User); var defautCurrency = currencyLogic.GetCurrencyByCode("HUF"); using (var db = new TimeTrackerModelContainer()) { var userInDb = db.User.FirstOrDefault(x => x.Email == email); if (userInDb != null) { throw new Exception("Ez az Email cím már regisztrált"); } newUser.Name = name; newUser.Email = email; newUser.Password = hashPassword; newUser.Phone = phone; newUser.Token = newToken; newUser.Role = defaultUserRole; db.Role.Attach(newUser.Role); db.User.Add(newUser); newTeam.Name = newUser.Name; db.Team.Add(newTeam); newUserTeamLink.User = newUser; newUserTeamLink.Currency = defautCurrency; newUserTeamLink.PrivatePrice = "0"; newUserTeamLink.PublicPrice = "0"; newUserTeamLink.Team = newTeam; db.Currency.Attach(newUserTeamLink.Currency); db.UserTeamLink.Add(newUserTeamLink); db.SaveChanges(); } return(newUser); }
public static OpenGraphVM GetOpenGraphVMForPledge(Pledge pledge, HttpRequestBase Request, UrlHelper Url) { var amt = CurrencyLogic.ToCurrency(pledge.Contributors, pledge.Originator.Currency).ToString("0.00"); var currencyPrefix = CurrencyLogic.GetCurrencyPrefix(pledge.Originator.Currency); return(new OpenGraphVM() { type = "article", title = "Help Yourself, Helping Others", description = $"{currencyPrefix}{amt} Pledged to {pledge.Charity.Name}", image = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Content("~/Images/Photos/FB_SiteImage1.jpg")}" }); }
public ActionResult Delete(string id, string bankAccountId) { if (Request.IsAjaxRequest() && !String.IsNullOrEmpty(id) && !String.IsNullOrEmpty(bankAccountId)) { var tranasction = _readTransaction.GetTransactionById(id); var binder = new ToTransactionDeleteViewModel(); var currencyLogic = new CurrencyLogic(); var viewModel = binder.GetTransaction(tranasction, currencyLogic); return(PartialView("Delete", viewModel)); } return(View()); }
public ActionResult Details(string id, string bankAccountId) { if (Request.IsAjaxRequest() && !String.IsNullOrEmpty(id) && !String.IsNullOrEmpty(bankAccountId)) { var transaction = _readTransaction.GetTransactionById(id, bankAccountId); var binder = new ToTransactionDetailsViewModel(); var currencyLogic = new CurrencyLogic(); var viewModel = binder.GetViewModel(transaction, currencyLogic); return(PartialView("Details", viewModel)); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Cos poszło nie tak przy details.")); }
public ActionResult Create() { ViewBag.Teams = db.Teams.ToList(); var PledgeVM = new CreatePledgeVM(); PledgeVM.CurrencySymbol = CurrencyLogic.GetCurrencyPrefix(CurrentUser().Currency); PledgeVM.Pledge = new Pledge(); PledgeVM.Pledge.Contributors.Add(new PledgeContributors { Sinner = CurrentUser(), SinnerID = CurrentUser().Id }); return(View(PledgeVM)); }
public ActionResult Create(string bankAccountId, string userId) { if (User.Identity.GetUserId() == userId && !String.IsNullOrEmpty(bankAccountId)) { var bankAccount = _readBankAccount.GetBankAccountById(bankAccountId); var binder = new ToTransactionCreateViewModel(); var currencyLogic = new CurrencyLogic(); var viewModel = binder.GetViewModel(bankAccount, currencyLogic); return(PartialView("Create", viewModel)); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public TransactionEditViewModel GetViewModel(Model.Transaction transaction, CurrencyLogic currencyLogic) { var viewModel = new TransactionEditViewModel() { Id = transaction.Id, Name = transaction.Name, Balance = transaction.Amount, AccountBalance = transaction.AccountBalance, SetDate = transaction.SetDate, Description = transaction.Description, Currency = currencyLogic.GetCurrencyIconById(transaction.BankAccount.Currency), BankAccountId = transaction.BankAccount.Id, UserId = transaction.BankAccount.User.Id }; return(viewModel); }
public static SocialVM GetSocialVMForPledgeContribution(PledgeContributors PC, string PCIdent, HttpRequestBase Request, UrlHelper Url) { string blurb; if (PC.AmountAnonymous) { blurb = $"{PC.Sinner.UserName} made a pledge to {PC.Pledge.Charity.Name}"; } else { blurb = $"{PC.Sinner.UserName} pledged {CurrencyLogic.GetCurrencyPrefix(PC.Currency)}{PC.Amount} to {PC.Pledge.Charity.Name}"; } return(new SocialVM() { Type = SocialVM.SocialType.PledgeContribution, LinkID = PC.ID.ToString(), ShareURL = Url.Action("Details", "Pledges", new { id = PC.Pledge.PledgeID }, protocol: Request.Url.Scheme) + "#" + PCIdent, Blurb = blurb }); }
public ActionResult LoadTransactionBySearchName(string name, string bankAccountId) { if (Request.IsAjaxRequest() && !String.IsNullOrEmpty(bankAccountId) && !String.IsNullOrEmpty(name)) { var currencyLogic = new CurrencyLogic(); var binder = new ToTransactionListViewModel(); var bankAccount = _readBankAccount.GetBankAccountById(bankAccountId); var transaction = _readTransaction.GetTransactionByName(name, bankAccountId); var viewModelTransaction = binder.GetTransactions(transaction, currencyLogic.GetCurrencyIconById(bankAccount.Currency)).ToPagedList(1, 1); return(PartialView("TransactionList", viewModelTransaction)); } return(new JsonResult() { Data = "Wystąpił błąd podczas operacji wczytywania transakcji po nazwie.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult GetTransactionsByBankAccountId(string bankAccountId, int page = 1, int selectedItemsForPage = 1) { if (!String.IsNullOrEmpty(bankAccountId)) { var bankAccount = _readBankAccount.GetBankAccountById(bankAccountId); var binder = new ToTransactionListViewModel(); var currencyLogic = new CurrencyLogic(); var filterLogic = new FiltersLogic(); var itemsForPage = filterLogic.GetItemsForPageById(selectedItemsForPage); var viewModelTransactions = binder.GetTransactions(bankAccount.Transactions, currencyLogic.GetCurrencyIconById(bankAccount.Currency)).ToPagedList(page, itemsForPage); return(PartialView("TransactionList", viewModelTransactions)); } else { return(new JsonResult { Data = "Wystąpił błąd podczas operacji.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public ActionResult DisplayAmountTotal(List <PledgeContributors> PCList, String OutputCurrencyCode) { Response.StatusCode = (int)HttpStatusCode.OK; return(Content(CurrencyLogic.GetDisplayAmount(PCList, OutputCurrencyCode, CurrentUser()?.Currency), MediaTypeNames.Text.Html)); }
public ActionResult DisplayAmount(string InputAmount, String InputCurrencyCode, String OutputCode) { Response.StatusCode = (int)HttpStatusCode.OK; return(Content(CurrencyLogic.GetDisplayAmount(InputAmount, InputCurrencyCode, OutputCode, CurrentUser()?.Currency), MediaTypeNames.Text.Html)); }
public BankAccountDetailsViewModel GetViewModel(Model.BankAccount bankAccount, CurrencyLogic currencyLogic) { var viewModel = new BankAccountDetailsViewModel() { Id = bankAccount.Id, Name = bankAccount.Name, Balance = bankAccount.Balance, Currency = currencyLogic.GetCurrencyIconById(bankAccount.Currency), User = bankAccount.User, SelectedItemsForPageId = 1 }; return(viewModel); }
public TransactionCreateViewModel GetViewModel(Model.BankAccount bankAccount, CurrencyLogic currencyLogic) { var viewModel = new TransactionCreateViewModel { AccountBalance = bankAccount.Balance, Currency = currencyLogic.GetCurrencyIconById(bankAccount.Currency), BankAccountId = bankAccount.Id, UserId = bankAccount.User.Id }; return(viewModel); }