public Contract(string number, string phoneNumber, TariffPlan tariffPlan, string personalAccount, string dateOfConclusion) { Number = number; PhoneNumber = new PhoneNumber { Value = phoneNumber }; TariffPlan = tariffPlan; DateOfConclusion = DateTime.Parse(dateOfConclusion); PersonalAccount = new PersonalAccount(personalAccount, DateOfConclusion + new TimeSpan(31, 0, 0)); }
public ActionResult Create([Bind(Include = "Id,HouseholdId,Name,Balance,ReconciledBalance,CreatedById,IsDeleted")] PersonalAccount personalAccount) { if (ModelState.IsValid) { db.PersonalAccounts.Add(personalAccount); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CreatedById = new SelectList(db.Users, "Id", "FirstName", personalAccount.CreatedById); ViewBag.HouseholdId = new SelectList(db.Households, "Id", "Name", personalAccount.HouseholdId); return(View(personalAccount)); }
public void CreatePersonalAccount_saves_a_PersonalAccount_via_context() { var options = new DbContextOptionsBuilder <IpsDBContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; // Run the test against one instance of the context using (var context = new IpsDBContext(options)) { var service = new PersonalAccountService(context); List <AssociatedIndividual> associatedIndividuals = new List <AssociatedIndividual>() { new AssociatedIndividual { AccountTypeId = 1, DateofBirth = new DateTime(2011, 10, 1), FirstName = "Rahul", LastName = "Mahajan", Title = "Mr" }, new AssociatedIndividual { AccountTypeId = 1, DateofBirth = new DateTime(2011, 10, 1), FirstName = "Vishal", LastName = "Mahajan", Title = "Mr" } }; PersonalAccount personalAccount = new PersonalAccount { AccountName = "My Accounts 1", AccountNo = "123456", BSB = "123", FirstName = "Karim", LastName = "Meghani", TFN = "XYZ1234", AssociatedIndividualPersonal = associatedIndividuals }; service.AddPersonalAccount(personalAccount); context.SaveChanges(); } // Use a separate instance of the context to verify correct data was saved to database using (var context = new IpsDBContext(options)) { Assert.Equal(1, context.PersonalAccount.Count()); } }
// GET: PersonalAccounts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PersonalAccount personalAccount = db.PersonalAccounts.Find(id); if (personalAccount == null) { return(HttpNotFound()); } return(View(personalAccount)); }
private async Task Authenticate(PersonalAccount account) { var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, account.Employee.EmployeeId.ToString()), new Claim(ClaimsIdentity.DefaultRoleClaimType, account.Employee.Role.Name), new Claim(ClaimTypes.Name, account.Employee.FirstName), new Claim(ClaimTypes.Surname, account.Employee.LastName), new Claim(ClaimTypes.GivenName, account.Login) }; ClaimsIdentity id = new ClaimsIdentity(claims, "ApplicationCookie", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(id)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { ApplicationDbContext db = new ApplicationDbContext(); var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { PersonalAccount personalAcc = new PersonalAccount() { Names = model.Name, Surname = model.Surname, PhoneNumber = model.PhoneNumber, Province = "", City = "", AppUserId = user.Id }; db.personalaccounts.Add(personalAcc); db.SaveChanges(); ActiveProfile ap = new ActiveProfile() { ApplicationUserId = user.Id, AccountType = "Personal", ActiveProfileID = personalAcc.ID }; db.activeprofiles.Add(ap); db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Create", "ProfilePics")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
// GET: PersonalAccounts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PersonalAccount personalAccount = db.PersonalAccounts.Find(id); if (personalAccount == null) { return(HttpNotFound()); } ViewBag.HouseholdId = new SelectList(db.Households, "Id", "Name", personalAccount.HouseholdId); return(View(personalAccount)); }
public ActionResult Create([Bind(Include = "Name,Balance,ReconciledBalance,IsDeleted")] PersonalAccount personalAccount) { if (ModelState.IsValid) { personalAccount.HouseholdId = HttpContext.User.Identity.GetHouseholdId().Value; var user = db.Users.Find(User.Identity.GetUserId()); personalAccount.CreatedById = user.Id; personalAccount.IsDeleted = false; db.PersonalAccounts.Add(personalAccount); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(personalAccount)); }
// GET: PersonalAccounts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PersonalAccount personalAccount = db.PersonalAccounts.Find(id); if (personalAccount == null) { return(HttpNotFound()); } ViewBag.ReturnUrl = Request.UrlReferrer; return(View(personalAccount)); }
public ActionResult Create([Bind(Include = "Id,Name,InstitutionName,Balance")] PersonalAccount personalAccount, int HHID) { if (ModelState.IsValid) { personalAccount.HouseholdId = HHID; personalAccount.ReconciledBalance = personalAccount.Balance; personalAccount.CreatedById = User.Identity.GetUserId(); db.PersonalAccounts.Add(personalAccount); db.SaveChanges(); return(RedirectToAction("Index", "Home", new { id = personalAccount.HouseholdId })); } ViewBag.CreatedById = new SelectList(db.Users, "Id", "FirstName", personalAccount.CreatedById); ViewBag.HouseholdId = new SelectList(db.Households, "Id", "Name", personalAccount.HouseholdId); return(View(personalAccount)); }
public ActionResult OpenPersonalPic(string app_user_id) { PersonalAccount p_acc = db.personalaccounts.ToList().Where(x => x.AppUserId == app_user_id).FirstOrDefault(); ProfilePic ppic = db.profilepics.ToList().Where(x => x.UserId == p_acc.ID).FirstOrDefault(); if (ppic != null) { var pic = db.Files.OrderByDescending(x => x.ProfilePicID == ppic.ID).FirstOrDefault(); return(File(pic.Content, pic.ContentType)); } else { return(File("/Content/default.jpg", "image/jpeg")); } }
public ActionResult BulkOrder(int business_id, int personal_id, string time) { string myid = User.Identity.GetUserId(); ActiveProfile active = db.activeprofiles.ToList() .Where(x => x.ApplicationUserId == myid).FirstOrDefault(); PersonalAccount customer = db.personalaccounts.ToList().Where(x => x.ID == personal_id).FirstOrDefault(); ListOrder listorder = db.listorders.ToList() .Where(x => x.BusinessID == business_id && x.PersonalAccID == personal_id && x.Date.TimeOfDay.ToString().Substring(0, 5) == time) .FirstOrDefault(); List <ProductListOrder> productorder = db.productlistorders.ToList() .Where(x => x.ListOrderID == listorder.ID).ToList(); List <Order> orders = new List <Order>(); double total = 0; bool im_business = false; foreach (ProductListOrder p in productorder) { Order order = db.orders.ToList().Where(x => x.ID == p.OrderID).FirstOrDefault(); if (order != null) { orders.Add(order); total += order.Price * order.Qauntity; } } if (listorder.BusinessID == active.ActiveProfileID) { im_business = true; } if (listorder.BusinessID == active.ActiveProfileID && listorder.Status == "Pending") { listorder.Status = "Seen"; db.SaveChanges(); } ViewBag.ImBusiness = im_business; ViewBag.OrderID = listorder.ID; ViewBag.Status = listorder.Status; ViewBag.Total = total; ViewBag.PersonalID = personal_id; ViewBag.CustomerName = customer.Names + " " + customer.Surname; return(View(orders)); }
public ActionResult CheckoutView() { string myId = User.Identity.GetUserId(); PersonalAccount p_acc = db.personalaccounts.ToList().Where(x => x.AppUserId == myId).FirstOrDefault(); List <Cart> carts = db.carts.ToList().Where(x => x.PersonalAccountID == p_acc.ID).ToList(); double balance = 0; foreach (Cart c in carts) { double price = c.Price * c.Qty; balance += price; } ViewBag.Balance = balance; return(View(carts)); }
public ActionResult Create([Bind(Include = "Id,HouseholdId,Name,Balance,ReconciledBalance,CreatedById,IsDeleted")] PersonalAccount personalAccount) { if (ModelState.IsValid) { //personalAccount.HouseholdId = User.Identity.GetHouseholdId().Value; personalAccount.CreatedById = User.Identity.GetUserId(); db.PersonalAccounts.Add(personalAccount); personalAccount.IsDeleted = false; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.CreatedById = new SelectList(db.Users, "Id", "FullName", personalAccount.CreatedById); ViewBag.HouseholdId = new SelectList(db.Households, "Id", "Name", personalAccount.HouseholdId); return(View(personalAccount)); }
/** * * Creates a new business account for a user * E.g User X creates an account for an IT Company * **/ public JsonResult AddProfile(BusinessAccountVM obj) { string myId = User.Identity.GetUserId(); PersonalAccount pa = db.personalaccounts.ToList().Where(x => x.AppUserId == myId).FirstOrDefault(); BusinessAccount ba = new BusinessAccount() { BusinessName = obj.BusinessName, BusinessType = obj.BusinessType, Email = obj.Email, Phone = obj.Phone, Website = obj.Website, Location = obj.Location, PersonalAccountID = pa.ID }; db.businessaccounts.Add(ba); db.SaveChanges(); return(Json(ba, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "Id,HouseholdId,Name,Balance,ReconciledBalance,CreatedById,IsDeleted")] PersonalAccount personalAccount) { if (ModelState.IsValid) { //var Bal = StringUtilities personalAccount.Balance //if (!Decimal.TryParse/*personalAccount.Balance != decimal*/) db.Entry(personalAccount).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CreatedById = new SelectList(db.Users, "Id", "FullName", personalAccount.CreatedById); ViewBag.HouseholdId = new SelectList(db.Households, "Id", "Name", personalAccount.HouseholdId); return(View(personalAccount)); }
// Use this for initialization /* * public StockReader ( string stockSymbol, string stockName, double number, double weight, int amount) * { * this.stockSymbol = stockSymbol; * this.stockName = stockName; * this.number = number; * this.weight = weight; * this.amount = amount; * * } */ public void Start() { Debug.Log("stuff should be here right?"); random = new System.Random(); stockPriceHistory = new List <double>(); Debug.Log("stockPriceHistory should be create now:"); Debug.Log(stockPriceHistory); this.currentPrice = (double)(number * (random.NextDouble() * (1.06 - .95) + .95)); this.percentage = (random.NextDouble() * (1.06 - .95) + .95); account = GameObject.Find("BankManager").GetComponent <PersonalAccount>(); this.AddCurrentPriceToHistory(currentPrice); for (int i = 0; i < 30; i++) { stockPriceHistory.Add((double)(number * (random.NextDouble() * (1.06 - .95) + .95))); //Debug.Log(stockPriceHistory[i]); } }
public async Task <ActionResult> Register(RegisterViewModel model) { try { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, MobilePhone = model.MobilePhone, City = model.City, Index = model.Index }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await UserManager.AddToRoleAsync(user.Id, "user"); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); PersonalAccount pa = new PersonalAccount(); pa.Balance = 0; pa.ApplicationUserId = user.Id; _factory.GetUserRepository(UserManager).AddAccount(pa); UserService.LockUser(UserManager, user.Id, false); logger.Info("Пользователь {0} зарегистрировался в системе", model.Email); //TempData["SuccessMessage"] = "Пользователь успшено зарегистрирован в системе."; return(RedirectToAction("Index", "Home")); } AddErrors(result); } return(View(model)); } catch (Exception ex) { logger.Error(ex, ex.Message); return(View("Error", new HandleErrorInfo(ex, "Account", "Register"))); } }
public ActionResult CompanyProducts(int id) { string myid = User.Identity.GetUserId(); PersonalAccount p = db.personalaccounts.ToList().Where(x => x.AppUserId == myid).FirstOrDefault(); BusinessAccount business = db.businessaccounts.ToList().Where(x => x.ID == id).FirstOrDefault(); if (business.PersonalAccountID == p.ID) { int items = db.carts.ToList().Where(x => x.PersonalAccountID == p.ID).ToList().Count(); ViewBag.Items = items; ViewBag.MyID = p.ID; return(View(db.profilepic_products.ToList() .Where(x => x.BusinessId == id).OrderByDescending(x => x.ID))); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Delete(Guid Id) { var status = "error"; try { if (!Authenticated) { status = "SESSION EXPIRED"; } else { PersonalAccount obj = new PersonalAccount(); PersonalAccount objexp = db.PersonalAccounts.Where(x => x.UID == Id).FirstOrDefault(); objexp.Status = 2; if (db.SaveChanges() > 0) { var ListRelation = (from s in db.PersonalAccounts where s.Status == 1 select new { UID = s.UID, Date = s.Date, Receive = s.Receive, Paid = s.Paid, Comments = s.Comments, }).ToList(); status = JsonConvert.SerializeObject(ListRelation); } } } catch (Exception ex) { ApplicationExceptionLogging(ex.Message, ex.StackTrace, "DailyExpenseController", "Edit"); } return(Content(status)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PersonalAccount personalAccount = db.PersonalAccounts.Find(id); if (personalAccount == null) { return(HttpNotFound()); } var debits = personalAccount.Transactions.Where(t => t.Type == false).Sum(t => t.Amount); ViewBag.Balance = (personalAccount.Balance - debits); var credits = personalAccount.Transactions.Where(t => t.Type == true).Sum(t => t.Amount); ViewBag.Balance += credits; var dtrx = personalAccount.Transactions.Where(t => t.Type == false && t.Reconciled == true).Sum(t => t.Amount); ViewBag.RecBalance = (personalAccount.Balance - dtrx); var ctrx = personalAccount.Transactions.Where(t => t.Type == true && t.Reconciled == true).Sum(t => t.Amount); ViewBag.RecBalance += ctrx; return(View(personalAccount)); //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} //PersonalAccount personalAccount = db.PersonalAccounts.Find(id); //if (personalAccount == null) //{ // return HttpNotFound(); //} //return View(personalAccount); }
public async Task <IActionResult> Login(PersonalAccount model) { if (ModelState.IsValid) { var user = await _context.PersonalAccounts .Include(x => x.Employee) .ThenInclude(x => x.Role) .FirstOrDefaultAsync(u => u.Login == model.Login && u.Password == model.Password); if (user != null) { await Authenticate(user); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Incorrect login or password"); } return(View(model)); }
public PlanCertificateSetGroupState(PlanCertificate planCertificate, PersonalAccount personalAccount) { Rn = planCertificate.Rn; PersonalAccount = personalAccount.Numb; }
/// <summary> /// Method for the execution of payment /// </summary> /// <param name="factory"></param> /// <param name="userId"></param> /// <param name="payment"></param> /// <param name="account"></param> /// <param name="sum"></param> /// <param name="logger"></param> public static void ExecutionOfPayment(IRepositoryFactory factory, string userId, Payment payment, PersonalAccount account, double sum, Logger logger) { var userPublications = GetAllUnpaidUserPublications(factory, userId); payment.OperationDate = DateTime.Now; payment.PersonalAccountId = account.PersonalAccountId; payment.Amount = sum; account.Balance -= payment.Amount; foreach (var item in userPublications) { item.StartDate = DateTime.Now; item.EndDate = item.StartDate.AddMonths(item.Period); item.PaymentState = true; logger.Info("Пользователь {0} оплатил подписку на {1} на период {2} месяц(ев) в сумме {3} грн с {4} по {5} ", item.User.Email, item.Publication.NameOfPublication, item.Period, item.Publication.PricePerMonth * item.Period, item.StartDate, item.EndDate); } factory.PaymentRepository.Add(payment); }
static void Main(string[] args) { DefaultLog.ClearLog(); Text.Title("-----< Loading >-----"); Console.Write("Loading items from database. Please wait... "); DateTime LoadStart = DateTime.Now; if (BankAPI.DataManager.LoadDb()) { DateTime LoadEnd = DateTime.Now; Text.Pass(); var Difference = (LoadEnd - LoadStart).TotalSeconds; Console.WriteLine("Loaded in {0} seconds", Difference); } else { Text.Fail(); } Text.Title("-----< /Loading >-----"); string GovernmentName = "MyGovernment"; string NewGovernmentName = "MyNewGovernment"; Government MyGovernment = null; Government MyNewGovernment = null; bool GovernmentSuccess = TestGovernment(); Console.WriteLine(); Person MyPerson = null; Person MyNewPerson = null; bool PersonSuccess = TestPerson(); Console.WriteLine(); Business MyBusiness = null; Business MyNewBusiness = null; bool BusinessSuccess = TestBusiness(); Console.WriteLine(); Bank MyBank = null; Bank MyNewBank = null; bool BankSuccess = TestBank(); Console.WriteLine(); PersonalAccount MyPersonalAccount = null; PersonalAccount MyNewPersonalAccount = null; bool PersonalAccountSuccess = TestPersonalAccount(); Console.WriteLine(); BusinessAccount MyBusinessAccount = null; BusinessAccount MyNewBusinessAccount = null; bool BusinessAccountSuccess = TestBusinessAccount(); Console.WriteLine(); Console.ReadLine(); bool TestGovernment() { Text.Title("-----< class Government >-----"); bool Success = true; Console.Write("Test 1 - Create new instance of class "); bool Test1 = true; MyGovernment = null; try { MyGovernment = new Government(GovernmentName); } catch { Test1 = false; Success = false; } if (Test1) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 2 - Insert into database "); if (Test1) { if (MyGovernment.DbInsert()) { Text.Pass(); } else { Success = false; Text.Fail(); //Console.ReadLine(); } } else { Text.Skipped(); } Console.Write("Test 3 - Change properties "); bool Test3 = true; try { MyGovernment.Name = NewGovernmentName; } catch { Success = false; Test3 = false; } if (Test3) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 4 - Update database "); if (Test3) { if (MyGovernment.DbUpdate()) { Text.Pass(); } else { Success = false; Text.Fail(); //Console.ReadLine(); } } else { Text.Skipped(); } Console.Write("Test 5 - Create new instance of class with the same Id "); bool Test5 = true; MyNewGovernment = null; try { MyNewGovernment = new Government(MyGovernment.Id); } catch { Success = false; Test5 = false; } if (Test5) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 6 - Select from database "); bool Test6 = true; if (Test5) { if (MyNewGovernment.DbSelect()) { Text.Pass(); } else { Test6 = false; Success = false; Text.Fail(); //Console.ReadLine(); } } else { Test6 = false; Text.Skipped(); } /*Console.Write("Test 7 - Validate from database "); * if (Test6) * { * try * { * if(MyGovernment.Id.ToString() != MyNewGovernment.Id.ToString()) * { * throw new Exception(); * } * * Text.Pass(); * } * catch * { * Success = false; * Text.Fail(); * //Console.ReadLine(); * } * } * else * { * Text.Skipped(); * }*/ Text.Title("-----<\\ class Government >-----"); return(Success); } bool TestPerson() { bool Success = true; Text.Title("-----< class Person >-----"); bool Test1 = true; Console.Write("Test 1 - Create new instance of class "); try { MyPerson = new Person("Joe", "Bloggs", MyGovernment); } catch { Test1 = false; } if (Test1) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 2 - Insert into database "); if (Test1) { if (MyPerson.DbInsert()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 3 - Change properties "); bool Test3 = true; try { MyPerson.Forename = "Jon"; MyPerson.Surname = "Doe"; } catch { Success = false; Test3 = false; } if (Test3) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 4 - Update database "); if (Test3) { if (MyPerson.DbUpdate()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 5 - Create new instance of class with the same Id "); bool Test5 = true; try { MyNewPerson = new Person(MyPerson.Id); } catch { Test5 = false; Success = false; } if (Test5) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 6 - Select from database "); if (Test5) { if (MyNewPerson.DbSelect()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Text.Title("-----<\\ class Person >-----"); return(Success); } bool TestBusiness() { Text.Title("-----< class Business >-----"); bool Success = true; Console.Write("Test 1 - Create new instance of class "); bool Test1 = true; try { MyBusiness = new Business(MyGovernment, MyPerson, "MyBusiness"); } catch { Test1 = false; } if (Test1) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 2 - Insert into database "); if (Test1) { if (MyBusiness.DbInsert()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 3 - Change properties "); bool Test3 = true; try { MyBusiness.Name = "Changed business name"; //MyBusiness.MyGovernment } catch { Success = false; Test3 = false; } if (Test3) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 4 - Update database "); if (Test3) { if (MyBusiness.DbUpdate()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 5 - Create new instance of class with the same Id "); bool Test5 = true; try { MyNewBusiness = new Business(MyBusiness.Id); } catch { Success = false; Test5 = false; } if (Test5) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 6 - Select from database "); if (Test5) { if (MyNewBusiness.DbSelect()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Text.Title("-----<\\ class Business >-----"); return(Success); } bool TestBank() { bool Success = true; Text.Title("-----< class Bank >-----"); Console.Write("Test 1 - Create new instance of class "); bool Test1 = true; try { decimal TempSavingsInterestRate = Convert.ToDecimal(0.03); decimal TempLoanInterestRate = Convert.ToDecimal(0.05); MyBank = new Bank(MyGovernment, "MyBank", MyPerson, TempSavingsInterestRate, TempLoanInterestRate); } catch { Test1 = false; Success = false; } if (Test1) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 2 - Insert into database "); if (Test1) { if (MyBank.DbInsert()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 3 - Change properties "); bool Test3 = true; try { MyBank.Name = "Changed bank name"; } catch { Success = false; Test3 = false; } if (Test3) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 4 - Update database "); if (Test3) { if (MyBank.DbUpdate()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 5 - Create new instance of class with the same Id "); bool Test5 = true; try { MyNewBank = new Bank(MyBank.Id); } catch { Success = false; Test5 = false; } if (Test5) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 6 - Select from database "); if (Test5) { if (MyNewBank.DbSelect()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } Text.Title("-----<\\ class Bank >-----"); return(Success); } bool TestPersonalAccount() { bool Success = true; Text.Title("-----< class PersonalAccount >-----"); if (BankSuccess) { Console.Write("Test 1 - Create new instance of class "); bool Test1 = true; try { MyPersonalAccount = new PersonalAccount(MyPerson, MyBank); } catch { Test1 = false; Success = false; } if (Test1) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 2 - Insert into database "); if (Test1) { if (MyPersonalAccount.DbInsert()) { Text.Pass(); } else { Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 3 - Change properties "); bool Test3 = true; try { //MyPersonalAccount. } catch { Success = false; Test3 = false; } if (Test3) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 4 - Update database "); if (Test3) { if (MyPersonalAccount.DbUpdate()) { Text.Pass(); } else { Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 5 - Create new instance of class with the same Id "); bool Test5 = true; try { MyNewPersonalAccount = new PersonalAccount(MyPersonalAccount.Id); } catch { Test5 = false; Success = false; } if (Test5) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 6 - Select from database "); if (Test5) { if (MyNewPersonalAccount.DbSelect()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } } else { Text.Skipped("Skipped due to errors whilst testing \"Bank\" class. "); return(false); } Text.Title("-----<\\ class PersonalAccount >-----"); return(Success); } bool TestBusinessAccount() { bool Success = true; Text.Title("-----< class BusinessAccount >-----"); if (BankSuccess) { Console.Write("Test 1 - Create new instance of class "); bool Test1 = true; try { MyBusinessAccount = new BusinessAccount(MyBusiness, MyBank); } catch { Test1 = false; Success = false; } if (Test1) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 2 - Insert into database "); if (Test1) { if (MyBusinessAccount.DbInsert()) { Text.Pass(); } else { Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 3 - Change properties "); bool Test3 = true; try { //MyBusinessAccount. } catch { Success = false; Test3 = false; } if (Test3) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 4 - Update database "); if (Test3) { if (MyBusinessAccount.DbUpdate()) { Text.Pass(); } else { Text.Fail(); } } else { Text.Skipped(); } Console.Write("Test 5 - Create new instance of class with the same Id "); bool Test5 = true; try { MyNewBusinessAccount = new BusinessAccount(MyBusinessAccount.Id); } catch { Test5 = false; Success = false; } if (Test5) { Text.Pass(); } else { Text.Fail(); } Console.Write("Test 6 - Select from database "); if (Test5) { if (MyNewBusinessAccount.DbSelect()) { Text.Pass(); } else { Success = false; Text.Fail(); } } else { Text.Skipped(); } } else { Text.Skipped("Skipped due to errors whilst testing \"Bank\" class. "); Success = false; } Text.Title("-----<\\ class BusinessAccount >-----"); return(Success); } /*LogReader MyNewReader = new LogReader(@"F:\Coding\Bank\BankConsoleTest\bin\Debug\log.txt"); * MyNewReader.DisplayParsedLog();*/ }
public PlanReceiptOrderSetGroupState(PlanReceiptOrder planReceiptOrder, PersonalAccount personalAccount) { RnPlanReceiptOrder = planReceiptOrder.Rn; PersonalAccount = personalAccount.Numb; }
public void Edit(PersonalAccount item) { _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); }
public void Add(PersonalAccount item) { _db.PersonalAccounts.Add(item); _db.SaveChanges(); }
public void AddPersonalAccount(PersonalAccount personalAccount) { _context.Add(personalAccount); _context.SaveChanges(); }
public ActionResult Index(string search) { string myId = User.Identity.GetUserId(); ActiveProfile active_profile = db.activeprofiles.ToList(). Where(x => x.ApplicationUserId == myId).FirstOrDefault(); bool personal_account_is_active = false; string account_name = ""; string account_type = ""; int account_id; PersonalAccount personal_account = db.personalaccounts.ToList(). Where(x => x.AppUserId == myId).FirstOrDefault(); if (personal_account.ID == active_profile.ActiveProfileID) { personal_account_is_active = true; } else { personal_account_is_active = false; } if (personal_account_is_active) { account_name = personal_account.Names + " " + personal_account.Surname; account_type = active_profile.AccountType; account_id = personal_account.ID; } else { BusinessAccount business_account = new BusinessAccount(); List <BusinessAccount> b_accounts = db.businessaccounts.ToList(). Where(x => x.PersonalAccountID == personal_account.ID).ToList(); foreach (BusinessAccount ba in b_accounts) { if (ba.ID == active_profile.ActiveProfileID) { business_account = ba; break; } } account_name = business_account.BusinessName; account_type = active_profile.AccountType; account_id = business_account.ID; string business_type = business_account.BusinessType; } ViewBag.isPersonalAccount = personal_account_is_active; ViewBag.AccountName = account_name; ViewBag.AccountID = account_id; ViewBag.AccountType = account_type; ViewBag.Search = search; bool hasSearch = false; if (search != null) { List <Conversation> conversations = db.conversations.ToList() .Where(x => (x.FirstPersonID == account_id || x.SecondPersonID == account_id) && (x.LastMessage.ToLower().Contains(search.ToLower()) || x.FirstPersonDispName.ToLower().Contains(search.ToLower()) || x.SecondPersonDispName.ToLower().Contains(search.ToLower()))).ToList(); hasSearch = true; ViewBag.hasSearch = hasSearch; return(View(conversations.OrderByDescending(x => x.Date))); } else { List <Conversation> conversations = db.conversations.ToList() .Where(x => x.FirstPersonID == account_id || x.SecondPersonID == account_id).ToList(); ViewBag.hasSearch = hasSearch; return(View(conversations.OrderByDescending(x => x.Date))); } }
private void Create_Click(object sender, RoutedEventArgs e) { var firstName = FirstNameBox.Text; var lastName = LastNameBox.Text; var pesel = PeselBox.Text; var email = EmailBox.Text; var doB = DoB.Text; var street = StreetBox.Text; var city = CityBox.Text; var country = CountryBox.Text; var zipCode = ZipCodeBox.Text; var phone = PhoneBox.Text; var nameValidator = new NameValidator(); var mailValidator = new MailValidator(); var peselValidator = new PeselValidator(); var dobValidator = new DateOfBirthValidator(); var phoneValidator = new PhoneValidator(); if (!nameValidator.ValidateName(firstName)) { MessageBox.Show("Podałeś nieprawidłowę imię."); } else if (!nameValidator.ValidateName(lastName)) { MessageBox.Show("Podałeś nieprawidłowe nazwisko"); } else if (!peselValidator.ValidatePesel(pesel)) { MessageBox.Show("Podałeś nieprawidłowy numer PESEL"); } else if (!mailValidator.ValidateMail(email)) { MessageBox.Show("Podałeś nieprawidłowy adres Email"); } else if (!phoneValidator.ValidatePhoneNumber(phone)) { MessageBox.Show("Nieprawidłowy numer telefonu"); } else if (!dobValidator.ValidateDoB(doB)) { MessageBox.Show("Nieprawidłowa data urodzenia"); } else if (string.IsNullOrEmpty(street) || string.IsNullOrEmpty(zipCode) || string.IsNullOrEmpty(country) || string.IsNullOrEmpty(city)) { MessageBox.Show("Pole adresowe nie może być puste"); } else { var gender = (Gender)Enum.Parse(typeof(Gender), GenderComboBox.Text); var account = new BankAccount(); var personalAccount = new PersonalAccount(firstName, lastName, doB, gender, pesel, email, street, zipCode, country, phone, city, account) { BankAccount = { Balance = 0.0 } }; var filePath = Environment.CurrentDirectory + @"\" + "Personal_Accounts.xml"; var listToXml = new ListToXml(); listToXml.PersonalAccounts(personalAccount, filePath); Close(); } }