public ActionResult DeleteConfirmed(int id) { CustomerRegion customerRegion = db.CustomerRegions.Find(id); db.CustomerRegions.Remove(customerRegion); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ServiceResponse <GetCustomerRegionDto> > getCustomerAddress([FromServices] ICustomerService _customerService) { ServiceResponse <GetCustomerRegionDto> response = new ServiceResponse <GetCustomerRegionDto>(); ServiceResponse <GetCustomerDto> response1 = await _customerService.getCustomerById(1); CustomerRegion customerRegion = await _context.CustomerRegions .Include(x => x.Region) .FirstOrDefaultAsync(x => x.CustomerId == response1.Data.Id); response.Data = _mapper.Map <GetCustomerRegionDto>(customerRegion); return(response); }
public ActionResult Edit([Bind(Include = "Id,CountryId,CurrencyId,TimeZone,DateFormate,TimeFormate")] CustomerRegion customerRegion) { if (ModelState.IsValid) { db.Entry(customerRegion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CountryId = new SelectList(db.Countries, "Id", "Name", customerRegion.CountryId); ViewBag.CurrencyId = new SelectList(db.Currencies, "Id", "CurrencyName", customerRegion.CurrencyId); return(View(customerRegion)); }
// GET: CustomerRegions/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerRegion customerRegion = db.CustomerRegions.Find(id); if (customerRegion == null) { return(HttpNotFound()); } return(View(customerRegion)); }
// GET: CustomerRegions/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerRegion customerRegion = db.CustomerRegions.Find(id); if (customerRegion == null) { return(HttpNotFound()); } ViewBag.CountryId = new SelectList(db.Countries, "Id", "Name", customerRegion.CountryId); ViewBag.CurrencyId = new SelectList(db.Currencies, "Id", "CurrencyName", customerRegion.CurrencyId); return(View(customerRegion)); }
public List <CustomerRegion> GetCustomersPerRegion() { List <CustomerRegion> customersPerRegion = new List <CustomerRegion>(); using (SqlConnection connect = new SqlConnection(connectionString)) { try { connect.Open(); string querySql = "Select * from CustomerRegion"; using (SqlCommand cmdCustomersPerRegion = new SqlCommand(querySql, connect)) { using (SqlDataReader customersPerRegionReader = cmdCustomersPerRegion.ExecuteReader()) { while (customersPerRegionReader.Read()) { CustomerRegion customerPerRegion = new CustomerRegion() { RegionName = (string)customersPerRegionReader["RegionName"], CustomersPerRegion = (int)customersPerRegionReader["Perioxes"]//h8ele Nomoi edw dn kanw drop XD }; customersPerRegion.Add(customerPerRegion); } } } } catch (SqlException e) { Console.WriteLine("SQL EXCEPTION", e.Message); } catch (Exception e) { Console.WriteLine("Exception", e.Message); } return(customersPerRegion); } }