Ejemplo n.º 1
0
        public string Delete(int id)
        {
            try
            {
                IEnumerable <int>  listOfIds    = _salonManager.GetIds();
                List <OrderEntity> listOfOrders = (List <OrderEntity>)_orderManager.GetList();
                if (listOfOrders.Any(c => c.CustomerId == id))
                {
                    return($"Customer can't be deleted because there are orders with this customer");
                }

                if (listOfIds.Contains(id))
                {
                    _salonManager.Delete(id);
                    return($"Customer with id {id} deleted");
                }
                else
                {
                    throw new Exception($"Customer with id {id} doesen't found");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public OrderIndexModel Get(int page)
        {
            try
            {
                IEnumerable <OrderEntity> orders = _orderManager.GetList().OrderByDescending(x => x.DateOfProcedure);

                var count = orders.Count();

                int pageSize = 8;

                var items = orders.Skip((page - 1) * pageSize).Take(pageSize).ToList();

                List <OrderModel> ordersVM = new List <OrderModel>();
                foreach (OrderEntity c in items)
                {
                    CustomerEntity customer = _customerManager.GetSingle(c.CustomerId);
                    ServiceEntity  service  = _serviceManager.GetSingle(c.ServiceId);
                    StateEntity    state    = _stateManager.GetSingle(c.StatusId);

                    ordersVM.Add(new OrderModel
                    {
                        Id       = c.Id,
                        Customer = new CustomerModel
                        {
                            Id          = customer.Id,
                            FirstName   = customer.FirstName,
                            LastName    = customer.LastName,
                            PhoneNumber = customer.PhoneNumber,
                            Email       = customer.Email
                        },
                        Service = new ServiceModel
                        {
                            Id            = service.Id,
                            NameOfService = service.NameOfService,
                            Price         = service.Price
                        },
                        Price  = service.Price,
                        Date   = c.DateOfProcedure,
                        Status = new StateModel
                        {
                            Id          = state.Id,
                            OrderStatus = state.OrderStatus
                        }
                    });
                }

                PageModel       pageViewModel = new PageModel(count, page, pageSize);
                OrderIndexModel viewModel     = new OrderIndexModel
                {
                    PageViewModel = pageViewModel,
                    Order         = ordersVM.OrderByDescending(x => x.Date)
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public CustomerIndexModel Get(int page = 1)
        {
            try
            {
                IEnumerable <CustomerEntity> customers = _salonManager.GetList();

                var count = customers.Count();

                int pageSize = 8;

                var items = customers.Skip((page - 1) * pageSize).Take(pageSize).ToList();

                List <CustomerModel> customersVM = new List <CustomerModel>();
                foreach (CustomerEntity c in items)
                {
                    customersVM.Add(new CustomerModel
                    {
                        Id          = c.Id,
                        FirstName   = c.FirstName,
                        LastName    = c.LastName,
                        PhoneNumber = c.PhoneNumber,
                        Email       = c.Email
                    });
                }

                PageModel          pageViewModel = new PageModel(count, page, pageSize);
                CustomerIndexModel viewModel     = new CustomerIndexModel
                {
                    PageViewModel = pageViewModel,
                    Customer      = customersVM
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private void FormFilmIslemleri_Load(object sender, EventArgs e)
        {
            #region Film Türü Doldurma
            cbFilmTur.DataSource    = _filmTuruRepo.GetList().Select(x => new { filmid = x.FilmTurID, filmad = x.FilmTurAd }).ToList();
            cbFilmTur.DisplayMember = "filmad";
            cbFilmTur.ValueMember   = "filmid";
            #endregion

            #region Salon Türü Doldurma
            //var doluSalonlar = _filmRepo.GetList().Where(x => x.Vizyonda == true).Select(x => x.SalonID);
            cbSalon.DataSource    = _salonRepo.GetList().Select(x => new { x.SalonID, x.SalonAD }).ToList();
            cbSalon.DisplayMember = "SalonAD";
            cbSalon.ValueMember   = "SalonID";
            txtSalon.Text         = cbSalon.Text;
            #endregion

            #region Başlangıç Değerleri
            btnKaydet.Enabled   = false;
            btnGuncelle.Enabled = false;
            btnSil.Enabled      = false;
            //txtFilmAd.Enabled = false;
            //txtOyuncular.Enabled = false;
            //txtYonetmen.Enabled = false;
            //txtFilmSure.Enabled = false;
            dtpVizyonGiris.MinDate = DateTime.Today.Date;
            dtpVizyonCikis.MinDate = dtpVizyonGiris.Value;
            txtVizyonGiris.Enabled = false;
            txtVizyonCikis.Enabled = false;
            txtVizyonGiris.Text    = dtpVizyonGiris.Value.ToShortDateString();
            txtVizyonCikis.Text    = dtpVizyonCikis.Value.ToShortDateString();
            dtpVizyonCikis.Enabled = false;
            chkVizyonda.Checked    = true;
            txtSalon.Enabled       = false;
            #endregion

            DataGridViewDoldur();
            VizyondanCikicakFilmKontrol();
        }
Ejemplo n.º 5
0
        public ServiceIndexModel Get(int page = 1)
        {
            try
            {
                IEnumerable <ServiceEntity> customers = _salonManager.GetList();

                var count = customers.Count();

                int pageSize = 8;

                var items = customers.Skip((page - 1) * pageSize).Take(pageSize).ToList();

                List <ServiceModel> servicesVM = new List <ServiceModel>();
                foreach (ServiceEntity c in items)
                {
                    servicesVM.Add(new ServiceModel
                    {
                        Id            = c.Id,
                        NameOfService = c.NameOfService,
                        Price         = c.Price
                    });
                }

                PageModel         pageViewModel = new PageModel(count, page, pageSize);
                ServiceIndexModel viewModel     = new ServiceIndexModel
                {
                    PageViewModel = pageViewModel,
                    Service       = servicesVM
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public IEnumerable <StateModel> GetStates()
        {
            try
            {
                IEnumerable <StateEntity> customers = _salonManager.GetList();

                List <StateModel> statesVM = new List <StateModel>();
                foreach (StateEntity c in customers)
                {
                    statesVM.Add(new StateModel
                    {
                        Id          = c.Id,
                        OrderStatus = c.OrderStatus
                    });
                }

                return(statesVM);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 private void SalonlariDoldur()
 {
     cbSalonlar.DataSource    = _salonRepo.GetList();
     cbSalonlar.ValueMember   = "SalonID";
     cbSalonlar.DisplayMember = "SalonAd";
 }