コード例 #1
0
        public RentalItemDto GetRentalItemById(int id)
        {
            DVDRentalEntities db = new DVDRentalEntities();

            var ri = db.RentalItems.FirstOrDefault(x => x.ID == id);
            return new RentalItemDto { ID = ri.ID.ToString(), Name = ri.Name, Price = ri.Price.ToString(), Type = ri.Type.ToString() };
        }
コード例 #2
0
        public NotificationDto GetNotificationById(int id)
        {
            DVDRentalEntities db = new DVDRentalEntities();

            var n = db.Notifications.FirstOrDefault(x => x.ID == id);
            return new NotificationDto { ID = n.ID.ToString(), Date = n.Date.ToString(), CustomerID = n.CustomerID.ToString() };
        }
コード例 #3
0
ファイル: SalesBLL.cs プロジェクト: josh1zn/DVDRentalSystem
 public void updateBalance(int customerID, int rentalID)
 {
     DVDRentalEntities db = new DVDRentalEntities();
      var customer = db.Users.FirstOrDefault(x => x.ID == customerID);
      customer.Balance += Convert.ToDecimal(new RentalItemBLL().GetRentalItemById(rentalID).Price);
      db.SaveChanges();
 }
コード例 #4
0
 //Add notifications that use the getUserFines method in the user class.
 public void AddNotification(int cid)
 {
     var db = new DVDRentalEntities();
     var n = new Notification
     {
         Date = DateTime.Now,
         CustomerID = cid,
     };
     db.Notifications.Add(n);
     db.SaveChanges();
 }
コード例 #5
0
ファイル: SalesBLL.cs プロジェクト: josh1zn/DVDRentalSystem
 //Add a sale into the database.
 public void AddSales(int rid,int cid,int eid)
 {
     var db = new DVDRentalEntities();
      var s = new Sale
      {
          Date= DateTime.Now,
          RentalItemID=rid,
          CustomerID=cid,
          EmployeeID=eid,
      };
      db.Sales.Add(s);
      db.SaveChanges();
 }
コード例 #6
0
 public List<NotificationDto> GetAllNotificationsByDate(string date)
 {
     DVDRentalEntities db = new DVDRentalEntities();
     List<NotificationDto> LRI = new List<NotificationDto>();
     DateTime dtstring = Convert.ToDateTime(date);
     foreach (var n in db.Notifications.Where(x => x.Date == dtstring))
     {
         LRI.Add(new NotificationDto
         {
             ID = n.ID.ToString(),
             Date = n.Date.ToString(),
             CustomerID = n.CustomerID.ToString(),
         });
     }
     return LRI;
 }
コード例 #7
0
        public List<NotificationDto> GetAllNotifications()
        {
            DVDRentalEntities db = new DVDRentalEntities();
            List<NotificationDto> LRI = new List<NotificationDto>();

            foreach (var n in db.Notifications)
            {
                LRI.Add(new NotificationDto
                {
                    ID = n.ID.ToString(),
                    Date = n.Date.ToString("dd MMM yyyy H:mm"),
                    CustomerID = n.CustomerID.ToString(),
                    FName = n.User.Name + " " + n.User.Surname,
                });
            }
            return LRI;
        }
コード例 #8
0
        public List<RentalItemDto> GetAllRentalItemsByType(string type)
        {
            DVDRentalEntities db = new DVDRentalEntities();
            List<RentalItemDto> LRI = new List<RentalItemDto>();

            foreach (var ri in db.RentalItems.Where( x => x.Type == type))
            {
                LRI.Add(new RentalItemDto
                {
                    ID = ri.ID.ToString(),
                    Name = ri.Name,
                    Type = ri.Type,
                    Price = ri.Price.ToString()
                });
            }
            return LRI;
        }
コード例 #9
0
ファイル: UserBLL.cs プロジェクト: josh1zn/DVDRentalSystem
 public UserDto getCustomer(int id)
 {
     DVDRentalEntities db = new DVDRentalEntities();
     var c = db.Users.FirstOrDefault(x => x.Role.Equals("Customer", StringComparison.InvariantCultureIgnoreCase) && x.ID == id);
     var customer = new UserDto()
     {
         Name = c.Name,
         Surname = c.Surname,
         IDNumber = c.IDNumber,
         Address = c.Address,
         ContactNumber = c.ContactNumber,
         Email = c.Email,
         Balance = c.Balance.ToString(),
         Fine = c.Fine.ToString(),
         Username = c.Username
     };
     return customer;
 }
コード例 #10
0
ファイル: UserBLL.cs プロジェクト: josh1zn/DVDRentalSystem
        public void AddUser(string name, string surname, string idnumber, string address, string contactNumber, string email, string role, string username, string password)
        {
            DVDRentalEntities db = new DVDRentalEntities();
            string hashPass = new HashBLL().CreateHash(password);
            User u = new User
            {
                Name = name,
                Surname = surname,
                IDNumber = idnumber,
                Address = address,
                ContactNumber = contactNumber,
                Email = email,
                Role = role,
                Username = username,
                Password = hashPass
            };

            db.Users.Add(u);
            db.SaveChanges();
        }
コード例 #11
0
ファイル: UserBLL.cs プロジェクト: josh1zn/DVDRentalSystem
 public List<UserDto> getAllClerks()
 {
     DVDRentalEntities db = new DVDRentalEntities();
     var customers = db.Users.Where(x => x.Role.Equals(x.Role.Equals("Clerk", StringComparison.InvariantCultureIgnoreCase)));
     List<UserDto> LU = new List<UserDto>();
     foreach (var c in customers)
     {
         LU.Add(new UserDto
         {
             Name = c.Name,
             Surname = c.Surname,
             IDNumber = c.IDNumber,
             Address = c.Address,
             ContactNumber = c.ContactNumber,
             Email = c.Email,
             Balance = c.Balance.ToString(),
             Fine = c.Fine.ToString(),
             Username = c.Username
         });
     }
     return LU;
 }
コード例 #12
0
ファイル: UserBLL.cs プロジェクト: josh1zn/DVDRentalSystem
        //Get user fines for sending notifications page.Fines with a balance more then 0
        public List<UserDto> getUserFines()
        {
            DVDRentalEntities db = new DVDRentalEntities();
            var fines = db.Users.Where(x => x.Fine > 0);
            List<UserDto> FU = new List<UserDto>();

            foreach (var f in fines)
            {
                FU.Add(new UserDto
                {
                    ID=f.ID.ToString(),
                    Name = f.Name,
                    Surname = f.Surname,
                    IDNumber = f.IDNumber,
                    Address = f.Address,
                    ContactNumber = f.ContactNumber,
                    Email = f.Email,
                    Balance=f.Balance.ToString(),
                    Fine = f.Fine.ToString(),
                });
            }
            return FU;
        }
コード例 #13
0
ファイル: UserBLL.cs プロジェクト: josh1zn/DVDRentalSystem
 public UserDto getUserCredentials(string username)
 {
     DVDRentalEntities db = new DVDRentalEntities();
     var u = db.Users.FirstOrDefault(x => x.Username.Equals(username, StringComparison.InvariantCultureIgnoreCase));
     if (u != null)
     {
         return new UserDto()
         {
             ID = u.ID.ToString(),
             Username = u.Username,
             Password = u.Password,
             Role = u.Role
         };
     }
     else
         return null;
 }