Exemple #1
0
        public ActionResult Details(int id)
        {
            var user           = _context.User.Include(c => c.AddressInfo).Include(c => c.Company).SingleOrDefault(c => c.Id == id);
            var exchange       = _context.Exchange.Include(c => c.Contact).Include(c => c.User).SingleOrDefault(c => c.User.Id == id);
            var lotsofcustomer = _context.Customer.Include(c => c.AddressInfo).ToList();
            var lotsofcompany  = _context.Company.Include(c => c.AddressInfo).ToList();
            var contact        = _context.Contact.Include(c => c.Customer).Include(c => c.AddressInfo).Single();
            //var docs = _context.Document.Single();
            //var mails = _context.Email.Include(c => c.Contact).SingleOrDefault(c=>c.ContactId==contact.Id);

            var messages = _context.Message.Include(c => c.Exchange).ToList();

            var viewModel = new ViewCustomer
            {
                User           = user,
                LotsOfCustomer = lotsofcustomer,
                Company        = lotsofcompany
            };

            if (user == null || id == null)
            {
                return(RedirectToAction("Index", "User"));
            }

            return(View(viewModel));
        }
Exemple #2
0
        private void ClientsBoutton_Click(object sender, RoutedEventArgs e)
        {
            CleanPanel();
            ViewCustomer viewCustomer = new ViewCustomer();

            this.dockPanelMain.Children.Add(viewCustomer);
        }
Exemple #3
0
        public List <ViewCustomer> Display()
        {
            List <ViewCustomer> viewCustomers = new List <ViewCustomer>();

            string        sqlString     = @"Server=FATEMA-PC\SQLEXPRESS; Database=SMS; Integrated Security=True";
            SqlConnection sqlConnection = new SqlConnection(sqlString);

            string     commandString = @"SELECT * FROM Customers";
            SqlCommand sqlCommand    = new SqlCommand(commandString, sqlConnection);

            sqlConnection.Open();

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                ViewCustomer viewCustomer = new ViewCustomer();

                viewCustomer.ID           = Convert.ToInt32(sqlDataReader["ID"]);
                viewCustomer.Code         = sqlDataReader["Code"].ToString();
                viewCustomer.Name         = sqlDataReader["Name"].ToString();
                viewCustomer.Address      = sqlDataReader["Address"].ToString();
                viewCustomer.Email        = sqlDataReader["Email"].ToString();
                viewCustomer.Contact      = sqlDataReader["Contact"].ToString();
                viewCustomer.LoyaltyPoint = Convert.ToDouble(sqlDataReader["LoyaltyPoint"].ToString());

                viewCustomers.Add(viewCustomer);
            }

            sqlConnection.Close();

            return(viewCustomers);
        }
        //View to Customers
        public Customers CreateCustumerModelFromViewModel(ViewCustomer viewCustomer)
        {
            var customers = new Customers()
            {
                FirstName   = viewCustomer.FirstName,
                LastName    = viewCustomer.LastName,
                PhoneNumber = viewCustomer.PhoneNumber,
                Email       = viewCustomer.Email,
                BirthDate   = viewCustomer.BirthDate,
                City        = viewCustomer.City,
                Country     = viewCustomer.Country,
                GuId        = Guid.NewGuid()
            };

            if (viewCustomer.GuId == Guid.Empty)
            {
                viewCustomer.GuId = customers.GuId;
            }
            //if not contains employments
            if (viewCustomer.Employments.Count == 0)
            {
                return(customers);
            }
            foreach (var products in viewCustomer.Employments)
            {
                var productsModelFromDb = CreateEmploymentsModelFromDb(products);
                customers.Employments.Add(productsModelFromDb);
            }
            return(customers);
        }
        public void WhenIViewTheCustomer()
        {
            _storedCustomer.Should().NotBeNull();

            int customerId = _actor.AsksFor(StoredCustomerId.ForName(_storedCustomer.Name));

            _actor.AttemptsTo(ViewCustomer.WithId(customerId));
        }
Exemple #6
0
        // POST: api/Customers
        public async Task <ViewCustomer> PostCustomers(ViewCustomer customer)
        {
            var modelFromViewModel = factory.CreateCustumerModelFromViewModel(customer);
            await db.Customers.AddAsync(modelFromViewModel);

            await db.SaveChangesAsync();

            return(customer);
        }
        public async Task <IActionResult> PostCustomers([FromBody] ViewCustomer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var postCustomers = await customersManager.PostCustomers(customer);

            return(CreatedAtAction("GetCustomerById", postCustomers));
        }
        public void WhenIUpdateTheCustomerWithANewMobileNumberOf(string newMobileNumber)
        {
            _storedCustomer.Should().NotBeNull();

            int customerId = _actor.AsksFor(StoredCustomerId.ForName(_storedCustomer.Name));

            _actor.AttemptsTo(
                ViewCustomer.WithId(customerId),
                SendKeys.To(CustomerMaintenancePage.Mobile, newMobileNumber),
                Click.On(CustomerMaintenancePage.Save));
        }
Exemple #9
0
        // PUT: api/Customers/5
        public async Task <ViewCustomer> PutCustomers(int id, ViewCustomer viewCustomer)
        {
            var customerDb     = factory.CreateCustumerModelFromViewModel(viewCustomer);
            var customerLoadDb = await db.Customers.FirstOrDefaultAsync(x => x.Id == id);

            db.Customers.Attach(customerLoadDb);
            factory.CustomerPutMaker(customerDb, customerLoadDb);
            await db.SaveChangesAsync();

            return(factory.CreateViewCustumerModelFromDb(customerLoadDb));
        }
        private void CreateCustomer()
        {
            customer = new ViewCustomer("customer");

            customer.Wallet.AddCoins(1, 10);
            customer.Wallet.AddCoins(2, 30);
            customer.Wallet.AddCoins(5, 20);
            customer.Wallet.AddCoins(10, 15);

            customer.Refresh();
        }
 public async Task <IActionResult> PutCustomers([FromRoute] int id, [FromBody] ViewCustomer customer)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (!customersManager.CustomersExists(id))
     {
         return(NotFound());
     }
     return(Ok(await customersManager.PutCustomers(id, customer)));
 }
Exemple #12
0
        public List <ViewCustomer> Display()
        {
            List <ViewCustomer> viewCustomers = new List <ViewCustomer>();

            string        sqlString     = @"Server=MH-PC\SQLEXPRESS; Database=CustomerInformation; Integrated Security=True";
            SqlConnection sqlConnection = new SqlConnection(sqlString);

            string     commandString = @"SELECT * FROM CustomerDetailsView";
            SqlCommand sqlCommand    = new SqlCommand(commandString, sqlConnection);

            sqlConnection.Open();

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                //Customer customer = new Customer();

                //customer.ID = Convert.ToInt32(sqlDataReader["ID"]);
                //customer.Code = sqlDataReader["Code"].ToString();
                //customer.Name = sqlDataReader["Name"].ToString();
                //customer.Contact = sqlDataReader["Contact"].ToString();
                //customer.Address = sqlDataReader["District"].ToString();
                //customer.DistrictId = Convert.ToInt32(sqlDataReader["DistrictId"]);

                //customers.Add(customer);

                ViewCustomer viewCustomer = new ViewCustomer();

                viewCustomer.ID       = Convert.ToInt32(sqlDataReader["ID"]);
                viewCustomer.Code     = sqlDataReader["Code"].ToString();
                viewCustomer.Name     = sqlDataReader["Name"].ToString();
                viewCustomer.Contact  = sqlDataReader["Contact"].ToString();
                viewCustomer.Address  = sqlDataReader["Address"].ToString();
                viewCustomer.District = sqlDataReader["District"].ToString();

                viewCustomers.Add(viewCustomer);
            }

            sqlConnection.Close();

            return(viewCustomers);
        }
        //Customers to view
        public ViewCustomer CreateViewCustumerModelFromDb(Customers customers)
        {
            var c = new ViewCustomer
            {
                FirstName   = customers.FirstName,
                LastName    = customers.LastName,
                PhoneNumber = customers.PhoneNumber,
                Email       = customers.Email,
                BirthDate   = customers.BirthDate,
                City        = customers.City,
                Country     = customers.Country,
                GuId        = customers.GuId
            };

            foreach (var employment in customers.Employments)
            {
                var productsModelFromDb = CreateEmploymentsViewModel(employment);
                c.Employments.Add(productsModelFromDb);
            }
            return(c);
        }
        public ActionResult Edit(ViewCustomer customer)
        {
            var Data = new Customer
            {
                Id          = customer.Id,
                Name        = customer.Name,
                Type        = customer.Type,
                Address1    = customer.Address1,
                Address2    = customer.Address2,
                Website     = customer.Website,
                UpdatedBy   = User.Identity.Name,
                UpdatedDate = DateTime.Now,
            };

            if (ModelState.IsValid)
            {
                db.Entry(Data).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details/" + Data.Id));
            }
            return(View(customer));
        }
Exemple #15
0
        public List <ViewCustomer> GetCustomer()
        {
            List <Customer>     customers     = db.Customers.ToList();
            List <ViewCustomer> viewCustomers = new List <ViewCustomer>();

            foreach (Customer customer in customers)
            {
                ViewCustomer viewCustomer = new ViewCustomer()
                {
                    Id           = customer.Id,
                    FirstName    = customer.FirstName,
                    LastName     = customer.LastName,
                    Email        = customer.Email,
                    CustomerRole = customer.CustomerRole.ToString(),
                    Username     = customer.Username,
                    Password     = customer.Password
                };

                viewCustomers.Add(viewCustomer);
            }

            return(viewCustomers);
        }
        private void CreateVending()
        {
            vmachine = new ViewVending("vmachine");
            vmachine.MessageEvent += (s, e) =>
            {
                MessageBox.Show(e.Message);
            };

            vmachine.GoodsStorage.AddGoods("Чай", 13, 10);
            vmachine.GoodsStorage.AddGoods("Кофе", 18, 20);
            vmachine.GoodsStorage.AddGoods("Кофе с молоком", 21, 20);
            vmachine.GoodsStorage.AddGoods("Сок", 35, 15);

            vmachine.Wallet.AddCoins(1, 100);
            vmachine.Wallet.AddCoins(2, 100);
            vmachine.Wallet.AddCoins(5, 100);
            vmachine.Wallet.AddCoins(10, 100);

            vmachine.Refresh();

            vmwallet = new ViewCustomer(vmachine);
            vmwallet.Refresh();
        }
        public ActionResult Create(ViewCustomer customer)
        {
            var Data = new Customer
            {
                Name        = customer.Name,
                Type        = customer.Type,
                Address1    = customer.Address1,
                Address2    = customer.Address2,
                Website     = customer.Website,
                CreatedBy   = User.Identity.Name,
                CreatedDate = DateTime.Now
            };
            var DataContact = new CustomerContact
            {
                Title       = customer.Title,
                JobPosition = customer.JobPosition,
                ContactName = customer.ContactName,
                Email       = customer.Email,
                Phone       = customer.Phone,
                Mobile      = customer.Mobile,
                Notes       = customer.Notes,
                CreatedBy   = User.Identity.Name,
                CreatedDate = DateTime.Now
            };

            if (ModelState.IsValid)
            {
                db.Customers.Add(Data);
                db.SaveChanges();
                DataContact.CustomerId = Data.Id;
                db.CustomerContacts.Add(DataContact);
                db.SaveChanges();
                return(RedirectToAction("Details/" + Data.Id));
            }
            return(View(customer));
        }
Exemple #18
0
        public IHttpActionResult EditCustomer(string id, [Bind(Include = "Id,UserName,CusPhone,Gender,Age")] ViewCustomer viewCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Customer customer = new Customer();
            int      id_temp  = Convert.ToInt32(id);

            customer          = db.Customers.Where(c => c.Id == id_temp).FirstOrDefault();
            customer.UserName = viewCustomer.UserName;
            customer.CusPhone = viewCustomer.CusPhone;
            customer.Gender   = viewCustomer.Gender;
            customer.Age      = viewCustomer.Age;


            db.Entry(customer).State = EntityState.Modified;
            db.SaveChanges();
            return(Ok(new
            {
                result = true,
                message = "更新成功"
            }));
        }
Exemple #19
0
        private void btnFindCust_Click(object sender, EventArgs e)
        {
            ViewCustomer vc = new ViewCustomer(this, this.idioma);

            vc.ShowDialog(this);
        }