public bool CreateTransaction(CreateTransactionViewModel createViewModel)
        {
            var transaction = Utilities.CopyEntityFields <CreateTransactionViewModel, Transaction>(createViewModel);

            transaction.EmployeeId = _httpContext.HttpContext.Session.GetInt32("EmployeeId").Value;
            _context.Transactions.Add(transaction);
            return(_context.SaveChanges() > 0);
        }
Example #2
0
        public int CreateCourier(CreateCourierViewModel createCourier)
        {
            var courier = Utilities.CopyEntityFields <CreateCourierViewModel, Courier>(createCourier);

            _context.Couriers.Add(courier);
            _context.SaveChanges();

            return(courier.Id);
        }
Example #3
0
        public int CreateCustomer(CreateCustomerViewModel customerViewModel)
        {
            var customer = Utilities.CopyEntityFields <CreateCustomerViewModel, Customer>(customerViewModel);

            _context.Customers.Add(customer);
            _context.SaveChanges();

            return(customer.Id);
        }
Example #4
0
        public EmployeeViewModel Register(RegisterViewModel register)
        {
            var employee = _context.Employees.FirstOrDefault(x => x.Firstname.Equals(register.Firstname) && x.Lastname.Equals(register.Lastname) && x.Password.Equals(register.Password));

            if (employee != null)
            {
                return(null);
            }

            employee = Utilities.CopyEntityFields <RegisterViewModel, Employee>(register);
            _context.Employees.Add(employee);
            _context.SaveChanges();

            return(Utilities.CopyEntityFields <Employee, EmployeeViewModel>(employee));
        }
Example #5
0
        public void Seed()
        {
            if (_context.Couriers.Any())
            {
                return;
            }

            _context.Couriers.Add(new Models.Courier {
                Firstname = "Marko", Lastname = "Markovic"
            });
            _context.Couriers.Add(new Models.Courier {
                Firstname = "Marija", Lastname = "Maric"
            });
            _context.Couriers.Add(new Models.Courier {
                Firstname = "Ana", Lastname = "Anic"
            });
            _context.Couriers.Add(new Models.Courier {
                Firstname = "Nikola", Lastname = "Nikolic"
            });
            _context.Couriers.Add(new Models.Courier {
                Firstname = "Stefan", Lastname = "Stefanovic"
            });
            _context.SaveChanges();

            _context.Customers.Add(new Models.Customer
            {
                Firstname    = "Nikola",
                Lastname     = "Nikolic",
                Available    = 0,
                City         = "Belgrade",
                Country      = "Serbia",
                Street       = "Street 1",
                PostalCode   = 11000,
                IdentityCard = "0101991772020",
                AccountNo    = "1000001"
            });

            _context.Customers.Add(new Models.Customer
            {
                Firstname    = "Bojan",
                Lastname     = "Bojanic",
                Available    = 0,
                City         = "Belgrade",
                Country      = "Serbia",
                Street       = "Street 2",
                PostalCode   = 11000,
                IdentityCard = "0101991772021",
                AccountNo    = "1000002"
            });

            _context.Customers.Add(new Models.Customer
            {
                Firstname    = "Petar",
                Lastname     = "Petrovic",
                Available    = 0,
                City         = "Belgrade",
                Country      = "Serbia",
                Street       = "Street 3",
                PostalCode   = 11000,
                IdentityCard = "0101991772022",
                AccountNo    = "1000003"
            });

            _context.Customers.Add(new Models.Customer
            {
                Firstname    = "Slobodan",
                Lastname     = "Slobodanovic",
                Available    = 0,
                City         = "Belgrade",
                Country      = "Serbia",
                Street       = "Street 4",
                PostalCode   = 11000,
                IdentityCard = "0101991772024",
                AccountNo    = "1000004"
            });

            _context.SaveChanges();
        }