public async Task <JsonResult> AddCostumer(Costumer data) { if (ModelState.IsValid) { HashSet <string> hs = (HashSet <string>)Session["Costumers"]; if (hs.Contains(data.Id)) // checking if costumer is already exist. { return(await Task.Run(() => Json(1, JsonRequestBehavior.AllowGet))); } using (var db = new FleetMSEntities()) { try { db.Costumer.Add(data); await db.SaveChangesAsync(); //updating sessions hs.Add(data.Id); Session["Costumers"] = hs; List <Costumer> list = (List <Costumer>)Session["CostumersArray"]; list.Add(data); Session["CostumersArray"] = list; return(await Task.Run(() => Json(0, JsonRequestBehavior.AllowGet))); } catch (Exception e) { Console.WriteLine(e.Source); } } } return(await Task.Run(() => Json(1, JsonRequestBehavior.AllowGet))); }
public static ObservableCollection <Costumer> GetDefaultCostumers() { ObservableCollection <Costumer> result = new ObservableCollection <Costumer>(); StreamReader reader = new StreamReader("Helper/TestData.csv"); for (int count = m_MAX_NUMBER * 2; count < m_MAX_NUMBER * 3; count++) { Costumer costumer = new Costumer(); string line = File.ReadLines(m_PERSON_TESTDATA_PATH).Skip(count).Take(1).First(); string[] values = line.Split('|'); costumer.Id = count - (m_MAX_NUMBER * 2) + 1; costumer.Company = values[0]; costumer.FirstName = values[1]; costumer.LastName = values[2]; string[] birthday = values[3].Split('-'); costumer.Birthday = DateTime.Parse(string.Format("{1}-{0}-{2}", birthday[0], birthday[1], birthday[2])); costumer.Phone = values[4]; costumer.Adress = new Adress(count + 1, values[5], values[6], values[7]); costumer.Email = values[8]; result.Add(costumer); } return(result); }
public IEnumerable <T> FindAll(List <Dictionary <string, object> > keyValueParam) { var result = new List <Costumer>(); using (DBClass = new MSSQLDatabase()) { SqlCommand cmd = DBClass.GetStoredProcedureCommand("APP_GET_ALL_OUTLET_COSTUMER"); RoutinesParameterSetter.Set(ref cmd, keyValueParam); var reader = DBClass.ExecuteReader(cmd); while (reader.Read()) { var costumer = new Costumer(int.Parse(reader[9].ToString())); costumer.CustId = int.Parse(reader[0].ToString()); costumer.FirstName = reader[1].ToString(); costumer.LastName = reader[2].ToString(); costumer.Address = reader[3].ToString(); costumer.Phone = reader[4].ToString(); costumer.MobilePhone = reader[5].ToString(); costumer.Email = reader[6].ToString(); costumer.StatusId = int.Parse(reader[7].ToString()); costumer.Active = reader[8].ToString() == "True"; result.Add(costumer); } } return(result as List <T>); }
public async Task <IActionResult> Edit(int id, [Bind("IdCostumer,NamaCostumer,Nik,Alamat,NoHp,IdGender")] Costumer costumer) { if (id != costumer.IdCostumer) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(costumer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CostumerExists(costumer.IdCostumer)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdGender"] = new SelectList(_context.Gender, "IdGender", "IdGender", costumer.IdGender); return(View(costumer)); }
private static void CallExercicioMeasureUp() { Costumer customer1 = new Costumer { Name = "Janet" }; TestCustomer1(customer1); Costumer customer2 = new Costumer { Name = "Kim" }; TestCustomer2(ref customer2); Card card1 = new Card { Number = "1111" }; TestCard1(card1); Card card2 = new Card { Number = "2222" }; TestCard2(ref card2); Console.WriteLine("customer1: " + customer1.Name); Console.WriteLine("customer2: " + customer2.Name); Console.WriteLine("card1: " + card1.Number); Console.WriteLine("card2: " + card2.Number); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var item = JObject.Load(reader); object target = null; switch (item["Type"].Value <string>()) // this is the property differentiater { case "1": target = new Costumer(); break; case "2": target = new Supplyer(); break; case "3": target = new Manager(); break; default: throw new NotImplementedException(); } serializer.Populate(item.CreateReader(), target); return(target); }
public float totalprice(string ordernumber) //total price { IEnumerable <Ordered_Dish> result = dal.listorderedDishes(item => item.orderNumber == ordernumber); //small list of all orders with the same order number float sum = 0; foreach (var item in result) { Dish d = dal.listDishes(s => s.dishNumber == item.dishNumber).FirstOrDefault(); sum += ((d.dishPrice) * (item.amountOfDish));//calculates the total price } var result2 = from order in dal.listOreders() where order.orderNumber == ordernumber select order.costumerTz; foreach (var costumerr in result2) { Costumer cos = dal.listCostumers(item => item.tz == costumerr).FirstOrDefault(); //IEnumerable<Costumer> cos = dal.listCostumers(item => item.tz == costumerr);//small list of all orders with the same order number if (cos != null) { if (cos.membership == true)//if he is a membership so it is 10 percent off { sum -= sum / 10; return(sum); } } } return(sum); }
public IActionResult Create(Costumer item) { _context.costumers.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetTodo", new { id = item.Id }, item)); }
public ActionResult Add(Costumer pCliente) { db.Cliente.Add(pCliente); db.SaveChanges(); return(RedirectToAction("Index", "Costumer")); }
void Awake() { foodses = new Foods[7]; foodses[0] = new Sandwich(true, false, false, false, false); foodses[1] = new Sandwich(true, true, false, false, false); foodses[2] = new Sandwich(true, false, true, false, false); foodses[3] = new Sandwich(true, true, true, false, false); ////////////////////// orders = new Order[4]; // for (int i = 0; i < orders.Length; i++) { orders[0] = new Order(foodses[0], true, false, false); orders[1] = new Order(foodses[1], true, false, false); orders[2] = new Order(foodses[2], true, false, false); orders[3] = new Order(foodses[3], true, false, false); // } ///////////////////////////////////////////// moshtaries = new Costumer[4]; for (int i = 0; i < moshtaries.Length; i++) { moshtaries[i] = new Costumer(orders[i]); } //////////////// }
static void Main(string[] args) { Costumer costumer = new Costumer(); costumer.Print(); Console.ReadLine(); }
public ActionResult Create(Costumer costumer) { if (!ModelState.IsValid) { var viewModel = new NewCostumerViewModel { Costumer = costumer, MembershipTypes = _contex.MembershipTypes.ToList() }; return(View("New", viewModel)); } if (costumer.Id == 0) { _contex.Costumers.Add(costumer); } else { var costumeInDb = _contex.Costumers.Single(C => C.Id == costumer.Id); costumeInDb.Name = costumer.Name; costumeInDb.Birthdate = costumer.Birthdate; costumeInDb.MembershipTypeId = costumer.MembershipTypeId; costumeInDb.IsSubsctibedToNewsletter = costumer.IsSubsctibedToNewsletter; } _contex.SaveChanges(); return(RedirectToAction("CostumerList", "Costumers")); }
public ActionResult Save(Costumer Costumer) { ModelState.Remove("Costumer.Id"); if (!ModelState.IsValid) { var viewModel = new CostumerFormViewModel { Costumer = Costumer }; return(View("FormCostumer", viewModel)); } if (Costumer.Id == 0) { _dbContext.Costumers.Add(Costumer); } else { Costumer dbCostumerContext = _dbContext.Costumers.Single(m => m.Id == Costumer.Id); dbCostumerContext.Name = Costumer.Name; dbCostumerContext.Email = Costumer.Email; dbCostumerContext.IsSubscribedToNewsletter = Costumer.IsSubscribedToNewsletter; dbCostumerContext.MembershipTypeId = Costumer.MembershipTypeId; dbCostumerContext.canEdit = Costumer.canEdit; dbCostumerContext.ImageUrl = Costumer.ImageUrl; } _dbContext.SaveChanges(); return(RedirectToAction("Costumer")); }
private void btnQuestioning_Click(object sender, EventArgs e) { lblPlateError.Visible = false; Costumer costumer = CostumerProcess.GetCostumer(userName, password); plate = textBox1.Text; Vehicle vehicle = VehicleProcess.GetVehicle(plate); if (vehicle != null) { if (costumer.ID == vehicle.CID) { lblLabel.Text = Convert.ToString(vehicle.LID); lblPlate.Text = vehicle.Plate; lblClass.Text = Convert.ToString(vehicle.Grade) + ". Class"; lblBalance.Text = Convert.ToString(vehicle.Balance); linkLabel2.Visible = true; } else { lblPlateError.Text = "This vehicle is not your's!"; lblPlateError.Visible = true; } } else { lblPlateError.Text = "There is no vehicle!"; lblPlateError.Visible = true; } }
private void BtnCostumerAdd_Click(object sender, EventArgs e) { if (!Validation()) { return; } Costumer cost = new Costumer(); cost.FirstName = TxtFirstName.Text; cost.LastName = TxtLastName.Text; cost.Email = TxtEmail.Text; cost.PhoneNo = TxtPhoneNumber.Text; List <Costumer> cost1 = _context.Costumers.Where(c => c.FirstName.Contains(TxtFirstName.Text)).ToList(); foreach (var item in cost1) { if (item.FirstName == cost.FirstName) { LblFirstName.ForeColor = Color.Red; MessageBox.Show("Eyni Adlı Müştəri Olduğu Üçün Şəxs Əlavə Olunmadı", "Diqqət!"); ResetCostumerForm(); return; } } _context.Costumers.Add(cost); _context.SaveChanges(); MessageBox.Show("Yeni Müştəri Əlavə Olundu!"); FillCostumerData(); ResetCostumerForm(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,ImageId")] Costumer costumer) { if (id != costumer.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(costumer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CostumerExists(costumer.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ImageId"] = new SelectList(_context.Images, "Id", "Link", costumer.ImageId); return(View(costumer)); }
public static void NewUser(List <Costumer> costumerList) { Console.WriteLine("Enter Your name"); string name = Console.ReadLine(); Random rnd = new Random(); int cardNumber1 = rnd.Next(10000000, 99999999); int cardNumber2 = rnd.Next(10000000, 99999999); string cardNumberSTR = String.Concat(cardNumber1, cardNumber2); int pin = rnd.Next(1000, 9999); if (long.TryParse(cardNumberSTR, out long cardNumber)) { for (int i = 0; i < costumerList.Count; i++) { if (cardNumber == costumerList[i].CardNum) { Console.WriteLine("Try again"); return; } } Costumer user1 = new Costumer(name, cardNumber); user1.AddPin(pin); user1.AddBalance(); Console.WriteLine($"Your card number is:{cardNumber} your pin is {pin}"); costumerList.Add(user1); } }
public async Task <IActionResult> OnPostAddCardAsync() { base.IdentifyCostumer(); var client = new Yandex.Checkout.V3.Client(shopId: Strings.YandexShopId, secretKey: Strings.YandexAPIKey); var newPayment = new NewPayment { Amount = new Amount { Value = 1.00m, Currency = "RUB" }, SavePaymentMethod = true, Confirmation = new Confirmation { Type = ConfirmationType.Redirect, ReturnUrl = $"https://power-now.ru/costumer" }, PaymentMethodData = new PaymentMethod { Type = PaymentMethodType.BankCard }, Description = "Для привязки карты списываем сумму в 1 рубль, которую сразу же вернем на Вашу карту" }; Payment payment = client.CreatePayment(newPayment); string url = payment.Confirmation.ConfirmationUrl; await Costumer.SetOrderId(_appRepository, payment.Id); await Costumer.SetCardStatus(_appRepository, CardsStatus.Progress); return(Redirect(url)); }
private void btnSave_Click(object sender, EventArgs e) { if (txtBrand.Text == "" || txtModel.Text == "" || txtPlate.Text == "" || txtClass.Text == "") { lblBlanks.Text = "Please fill in the blanks"; } else { int len1, len2; string a, b; len1 = txtBrand.Text.Length; len2 = txtModel.Text.Length; a = txtBrand.Text.Substring(0, 1); b = txtModel.Text.Substring(0, 1); Vehicle vehicle = new Vehicle(); vehicle.Brand = a.ToUpper() + txtBrand.Text.Substring(1, len1 - 1); vehicle.Model = b.ToUpper() + txtModel.Text.Substring(1, len2 - 1); vehicle.Plate = txtPlate.Text; vehicle.Grade = txtClass.Text; Costumer costumer = CostumerProcess.GetCostumer(userName, password); vehicle.CID = costumer.ID; VehicleProcess.AddVehicle(vehicle); Questioning questioning = new Questioning(); questioning.userName = userName; questioning.password = password; questioning.Show(); this.Hide(); } }
public T FindbyId(int id) { Costumer costumer = null; using (DBClass = new MSSQLDatabase()) { SqlCommand cmd = DBClass.GetStoredProcedureCommand("APP_GET_OUTLET_COSTUMER"); cmd.Parameters.AddWithValue("@CustId", id); var reader = DBClass.ExecuteReader(cmd); while (reader.Read()) { costumer = new Costumer(int.Parse(reader[9].ToString())); costumer.CustId = int.Parse(reader[0].ToString()); costumer.FirstName = reader[1].ToString(); costumer.LastName = reader[2].ToString(); costumer.Address = reader[3].ToString(); costumer.Phone = reader[4].ToString(); costumer.MobilePhone = reader[5].ToString(); costumer.Email = reader[6].ToString(); costumer.StatusId = int.Parse(reader[7].ToString()); costumer.Active = reader[8].ToString() == "True"; } } return(costumer as T); }
static void Main(string[] args) { Costumer C1 = new Costumer(); C1.print(); C1.print2(); }
public void Put(int id, [FromBody] Costumer costumer) { var editedCostumer = costumers[0]; editedCostumer.Nome = costumer.Nome; editedCostumer.Email = costumer.Email; }
[Authorize]//checks if the user is loged in, IF NOT, it would send the user to the login page public ActionResult Checkout() { //User.Identity.Name (a built in asp .net security principle)-> from here we get the loged in email Costumer costumer = costumers.Collection().FirstOrDefault(c => c.Email == User.Identity.Name); if (costumer != null) { Order order = new Order() { Email = costumer.Email, City = costumer.City, State = costumer.State, Street = costumer.Street, FirstName = costumer.FirstName, Surname = costumer.LastName, ZipCode = costumer.ZipCode }; return(View(order));//for autofilling the user data in the checkout page } else { return(RedirectToAction("Error")); } }
public static LoginDto ChackPasswordCustomer(int id, string password) { UjewelriesDBContext db = new UjewelriesDBContext(); LoginDto dto = new LoginDto(); try { Costumer Selected = db.Costumers.Where(a => a.id == id).ToList().First(); dto.password = Selected.name; if (Selected.password == password) { if (Selected.is_manager == true) { dto.id = "Admin"; return(dto); } else { dto.id = "Client"; return(dto); } } } catch (System.Exception e) { Console.WriteLine("Password or Username wrong!!"); } dto.id = "false"; dto.id = ""; return(dto); }
public static void HomeScreen() { while (true) { Console.Clear(); Console.WriteLine("Select: \n \t 1.Log In. \n \t 2.Continue as Guest \n \t 3.Register \n \t 0.Exit"); switch (Console.ReadLine()) { case "1": try { Helper.SlowPrint("Loging in"); User user = LogInUi(ShopDB.Users); Console.Clear(); Console.WriteLine($"Hello {user.FirstName}"); if (user.Type == UserType.Buyer) { CostumerPannel((Costumer)user); } else if (user.Type == UserType.Manager) { ManagerPannel((Manager)user); } else if (user.Type == UserType.Supplyer) { SupplyerPannel((Supplyer)user); } }catch (Exception ex) { Console.WriteLine(ex.Message); } continue; case "2": Helper.SlowPrint("Guest entering"); Console.Clear(); GuestPannel(); Console.WriteLine("To see the prices please register and log in"); Console.ReadKey(); continue; case "3": Costumer newUser = RegisterPannel(); if (newUser != null) { ShopDB.Costumers.Add(newUser); } continue; case "0": Helper.SlowPrint("Exiting"); Console.Clear(); break; default: Helper.SlowPrint("Wrong Input Try again ...."); Console.Clear(); continue; } break; } }
public async Task <IActionResult> CreateCostumerAsync([FromBody] Costumer c) { var mapped = _mapper.Map <DAL.Entities.Costumer>(c); await _costumerService.AddCostumerAsync(mapped); return(CreatedAtRoute("GetCostumerById", new { id = mapped.Id }, mapped)); }
public void givenAListOfCostumers_WhenRegisterANewCostumerWithDuplicateEmail_ExceptionIsThrown() { Costumer costumer = new Costumer("test", "test", "*****@*****.**", "test", "Azerty123", new Adderss("hier", "8", "btown", "3350")); var exception = Assert.Throws <CostumerException>(() => costumerService.Register(costumer)); Assert.Equal("The costumer Email is already used. no duplicated is possible", exception.Message); }
public ActionResult Delete(Costumer pCliente) { Costumer cliente = db.Cliente.FirstOrDefault(a => a.CostumerID == pCliente.CostumerID); db.Cliente.Remove(cliente); db.SaveChanges(); return(RedirectToAction("Index", "Costumer")); }
protected void btnRegister_Click(object sender, EventArgs e) { Costumer costumer = new Costumer(tBoxName.Text, tBoxEmail.Text, tBoxPassword.Text); Service.Instance.createCostumer(costumer); Session["costumer"] = costumer.Email; Response.Redirect("Page1.aspx"); }
public async Task <ActionResult> DeleteConfirmed(int id) { Costumer costumer = await db.Costumers.FindAsync(id); db.Costumers.Remove(costumer); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
//Add a new company to the database private void btAddCompany_Click(object sender, EventArgs e) { //Error checking lblErrorCompany.Text = string.Empty; int kvk = 0; bool error = false; Costumer costumer = new Costumer(); //Check if input fields are empty if (tbCompanyName.Text == string.Empty) error = true; if (tbContactPerson.Text == string.Empty) error = true; //Check if empty if not check if its a number, continue if it is if (tbCompanyKvk.Text == string.Empty) { error = true; } else { try { kvk = Convert.ToInt32(tbCompanyKvk.Text); } catch (Exception ex) { error = true; } } if (cbMotherCompany.SelectedIndex == -1) { error = true; } //If there are no error add to database if(error != true) { //Check result in case of database failure costumer = costumers[cbMotherCompany.SelectedIndex]; bool succes = costumer.Add(costumer, tbCompanyName.Text, tbContactPerson.Text, kvk); //if succes refresh company list if (!succes) lblErrorCompany.Text = "Er is iets fout gegaan bij het wegschrijven"; else FillCompanyList(); } else { //show error lblErrorCompany.Text = "Controleer de gegevens"; } }
//Constr public deleteContainerForm(Costumer costumer) { InitializeComponent(); this.costumer = costumer; BindDataGrid(); }
public Account(Costumer costumer, decimal interestRate, decimal balance) { this.AccountCostumer = costumer; this.Balance = balance; this.InterestRate = interestRate; }
//When a company is selected add the company to the object and show values private void btSelectCompany_Click(object sender, EventArgs e) { costumer = costumers[listBCompany.SelectedIndex]; lblCompanySelected.Text = costumer.companyName; btDeleteContainers.Visible = Visible; }