コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CustomerRegion customerRegion = db.CustomerRegions.Find(id);

            db.CustomerRegions.Remove(customerRegion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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));
 }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        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);
            }
        }