Exemplo n.º 1
0
 public static bool Insert(VendorModel vendor)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblVendor newRow = new TblVendor()
             {
                 VendorID       = rc.TblVendors.Any() ? rc.TblVendors.Max(v => v.VendorID) + 1 : 1,
                 OwnerID        = vendor.OwnerID,
                 CompanyName    = vendor.CompanyName,
                 CompanyEmail   = vendor.CompanyEmail,
                 LicenseNumber  = vendor.LicenseNumber,
                 InspectionDate = vendor.InspectionDate,
                 Bio            = vendor.Bio,
                 Website        = vendor.Website,
                 Confirmed      = false
             };
             rc.TblVendors.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        public static bool Deactivate(int id)
        {
            try
            {
                if (id != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblMenu tblMenu = rc.TblMenus.FirstOrDefault(u => u.MenuID == id);

                        if (tblMenu != null)
                        {
                            tblMenu.IsActive = false;

                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Menu was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
 public static bool Insert(string Email, string firstname, string lastname, string Password, string Phone)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblUser newRow = new TblUser()
             {
                 UserID    = rc.TblUsers.Any()? rc.TblUsers.Max(u => u.UserID) + 1: 1,
                 Email     = Email,
                 FirstName = firstname,
                 LastName  = lastname,
                 Password  = Password,
                 Phone     = Phone
             };
             rc.TblUsers.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 public static MenuItemModel Insert(MenuItemModel menuItem)/*,int menuItem, string itemName,
                                                            * int price,string picture,string description,int menuSectionID)*/
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblMenuItem newRow = new TblMenuItem()
             {
                 ItemID        = rc.TblMenuItems.Any() ? rc.TblMenuItems.Max(u => u.ItemID) + 1 : 1,
                 ItemName      = menuItem.ItemName,
                 MenuID        = menuItem.MenuItem,
                 Price         = menuItem.Price,
                 Picture       = menuItem.Picture,
                 Description   = menuItem.Description,
                 MenuSectionID = menuItem.MenuSectionID
             };
             rc.TblMenuItems.Add(newRow);
             rc.SaveChanges();
             menuItem.ItemID = newRow.ItemID;
             return(menuItem);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 public static bool Insert(string menuItemname, int menuID, decimal price, string picture, int menusectionID, string desc)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblMenuItem newRow = new TblMenuItem()
             {
                 ItemID        = rc.TblMenuItems.Any() ? rc.TblMenuItems.Max(u => u.ItemID) + 1 : 1,
                 MenuID        = menuID,
                 ItemName      = menuItemname,
                 Price         = price,
                 Picture       = picture,
                 Description   = desc,
                 MenuSectionID = menusectionID
             };
             rc.TblMenuItems.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
 public static bool Insert(UserModel user)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblUser newRow = new TblUser()
             {
                 UserID      = rc.TblUsers.Any()? rc.TblUsers.Max(u => u.UserID) + 1: 1,
                 Email       = user.Email,
                 FirstName   = user.FirstName,
                 LastName    = user.LastName,
                 DOB         = user.DOB,
                 Password    = GetHash(user.Password).ToString(),
                 Phone       = user.Phone,
                 Deactivated = user.Deactivated,
                 Admin       = user.Admin
             };
             rc.TblUsers.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        // Unit tests only
        public static bool Delete(int id)
        {
            try
            {
                if (id != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        var vendorLocation = rc.TblVendorLocations.FirstOrDefault(v => v.VendorID == id);

                        if (vendorLocation != null)
                        {
                            rc.TblVendorLocations.Remove(vendorLocation);
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Vendor cannot be found");
                        }
                    }
                }
                else
                {
                    throw new Exception("ID cannot be 0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
 public static bool Insert(int Rating, string Subject, string Body)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblReview newRow = new TblReview()
             {
                 ReviewID = rc.TblReviews.Any() ? rc.TblReviews.Max(u => u.ReviewID) + 1 : 1,
                 VendorID = 1,
                 UserID   = 1,
                 Rating   = Rating,
                 Subject  = Subject,
                 Body     = Body
             };
             rc.TblReviews.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        // Unit tests only
        public static bool Delete(int ID)
        {
            try
            {
                if (ID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        var vendorEmployee = rc.TblVendorEmployees.FirstOrDefault(u => u.ID == ID);

                        if (vendorEmployee != null)
                        {
                            rc.TblVendorEmployees.Remove(vendorEmployee);
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("VendorEmployee cannot be found");
                        }
                    }
                }
                else
                {
                    throw new Exception("ID cannot be 0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 10
0
        public static bool Delete(int id)
        {
            try
            {
                if (id != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        var cuisine = rc.TblCuisines.FirstOrDefault(u => u.CuisineID == id);

                        if (cuisine != null)
                        {
                            rc.TblCuisines.Remove(cuisine);
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Item cannot be found");
                        }
                    }
                }
                else
                {
                    throw new Exception("ID cannot be 0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 11
0
        // Unit tests only
        public static bool Delete(int id)
        {
            try
            {
                if (id != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        var review = rc.TblReviews.FirstOrDefault(u => u.ReviewID == id);

                        if (review != null)
                        {
                            rc.TblReviews.Remove(review);
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Review cannot be found");
                        }
                    }
                }
                else
                {
                    throw new Exception("ID cannot be 0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 12
0
        public static OrderModel Insert(OrderModel order)
        {
            try
            {
                using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                {
                    PL.TblOrder newRow = new TblOrder()
                    {
                        OrderID   = rc.TblOrders.Any() ? rc.TblOrders.Max(u => u.OrderID) + 1 : 1,
                        VendorID  = order.VendorID,
                        UserID    = order.UserID,
                        OrderDate = order.OrderDate
                    };

                    order.OrderID = newRow.OrderID;
                    rc.TblOrders.Add(newRow);
                    rc.SaveChanges();
                    return(order);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 13
0
        // Unit tests only
        public static bool Delete(int id)
        {
            try
            {
                if (id != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        var menuSection = rc.TblMenuSections.FirstOrDefault(u => u.MenuSectionID == id);

                        if (menuSection != null)
                        {
                            rc.TblMenuSections.Remove(menuSection);
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Menu section cannot be found");
                        }
                    }
                }
                else
                {
                    throw new Exception("ID cannot be 0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
 public static bool Insert(int OwnerID, string CompanyName, string CompanyEmail, DateTime InspectionDate, string Bio, string Website)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblVendor newRow = new TblVendor()
             {
                 VendorID       = rc.TblVendors.Any() ? rc.TblVendors.Max(v => v.VendorID) + 1 : 1,
                 OwnerID        = OwnerID,
                 CompanyName    = CompanyName,
                 CompanyEmail   = CompanyEmail,
                 InspectionDate = InspectionDate,
                 Bio            = Bio,
                 Website        = Website,
                 Confirmed      = false
             };
             rc.TblVendors.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 15
0
        public static bool Deactivate(int id)
        {
            try
            {
                if (id != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblUser tblUser = rc.TblUsers.FirstOrDefault(u => u.UserID == id);

                        if (tblUser != null)
                        {
                            tblUser.Deactivated = true;
                            tblUser.Admin       = false;
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("User was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("ID cannot be 0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 16
0
        public static bool Update(MenuSectionModel menuSection)
        {
            try
            {
                if (menuSection.MenuSectionID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblMenuSection tblMenuSection = rc.TblMenuSections.FirstOrDefault(u => u.MenuSectionID == menuSection.MenuSectionID);

                        if (tblMenuSection != null)
                        {
                            tblMenuSection.DisplayOrderNum = menuSection.DisplayOrderNum;
                            tblMenuSection.MenuSectionName = menuSection.MenuSectionName;
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Menu section was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid ID");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 17
0
        public static bool Update(VendorModel vendor)
        {
            try
            {
                if (vendor.VendorID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblVendor tblVendor = rc.TblVendors.FirstOrDefault(v => v.VendorID == vendor.VendorID);

                        if (tblVendor != null)
                        {
                            tblVendor.VendorID       = vendor.VendorID;
                            tblVendor.OwnerID        = vendor.OwnerID;
                            tblVendor.CompanyName    = vendor.CompanyName;
                            tblVendor.CompanyEmail   = vendor.CompanyEmail;
                            tblVendor.LicenseNumber  = vendor.LicenseNumber;
                            tblVendor.InspectionDate = vendor.InspectionDate;
                            tblVendor.Bio            = vendor.Bio;
                            tblVendor.Website        = vendor.Website;
                            tblVendor.Confirmed      = vendor.Confirmed;
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Vendor was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 18
0
        public static bool Update(ReviewModel review)
        {
            try
            {
                if (review.ReviewID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblReview tblReview = rc.TblReviews.FirstOrDefault(u => u.ReviewID == review.ReviewID);

                        if (tblReview != null)
                        {
                            tblReview.ReviewID = review.ReviewID;
                            tblReview.UserID   = review.UserID;
                            tblReview.VendorID = review.VendorID;
                            tblReview.Rating   = review.Rating;
                            tblReview.Subject  = review.Subject;
                            tblReview.Body     = review.Body;


                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Review was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public static bool Insert(int UserID, int VendorID)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblVendorEmployee newRow = new TblVendorEmployee()
             {
                 ID       = rc.TblVendorEmployees.Any() ? rc.TblVendorEmployees.Max(u => u.ID) + 1 : 1,
                 UserID   = UserID,
                 VendorID = VendorID
             };
             rc.TblVendorEmployees.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 20
0
        public static bool Update(CuisineModel cuisine)
        {
            try
            {
                if (cuisine.CuisineID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblCuisine tblCuisine = rc.TblCuisines.FirstOrDefault(u => u.CuisineID == cuisine.CuisineID);

                        if (tblCuisine != null)
                        {
                            tblCuisine.CuisineID   = cuisine.CuisineID;
                            tblCuisine.VendorID    = cuisine.VendorID;
                            tblCuisine.MenuID      = cuisine.MenuID;
                            tblCuisine.CuisineName = cuisine.CuisineName;



                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Item was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 21
0
 public static bool Insert(int MenuItemID, decimal Price, int Quantity)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblOrderItem newRow = new TblOrderItem()
             {
                 OrderItemID = rc.TblOrderItems.Any() ? rc.TblOrderItems.Max(u => u.OrderItemID) + 1 : 1,
                 MenuItemId  = MenuItemID,
                 Price       = Price,
                 Quantity    = Quantity
             };
             rc.TblOrderItems.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 22
0
 public static bool Insert(int menu, int order, string menuSectionName)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblMenuSection newRow = new TblMenuSection()
             {
                 MenuSectionID   = rc.TblMenuSections.Any() ? rc.TblMenuSections.Max(u => u.MenuSectionID) + 1 : 1,
                 MenuID          = menu,
                 DisplayOrderNum = order,
                 MenuSectionName = menuSectionName
             };
             rc.TblMenuSections.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 23
0
 public static bool Insert(string cuisinename, int menuID, int vendorID)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblCuisine newRow = new TblCuisine()
             {
                 CuisineID   = rc.TblCuisines.Any() ? rc.TblCuisines.Max(u => u.CuisineID) + 1 : 1,
                 VendorID    = vendorID,
                 MenuID      = menuID,
                 CuisineName = cuisinename
             };
             rc.TblCuisines.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static bool Insert(int LocationX, int LocationY, DateTime Date)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblVendorLocation newRow = new TblVendorLocation()
             {
                 VendorID  = rc.TblVendorLocations.Any() ? rc.TblVendorLocations.Max(v => v.VendorID) + 1 : 1,
                 LocationX = LocationX,
                 LocationY = LocationY,
                 Datetime  = Date
             };
             rc.TblVendorLocations.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 25
0
        public static bool Update(OrderModel order)
        {
            try
            {
                if (order.OrderID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblOrder tblOrder = rc.TblOrders.FirstOrDefault(u => u.OrderID == order.OrderID);

                        if (tblOrder != null)
                        {
                            tblOrder.OrderID   = order.OrderID;
                            tblOrder.UserID    = order.OrderID;
                            tblOrder.VendorID  = order.OrderID;
                            tblOrder.OrderDate = order.OrderDate;


                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Order was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 26
0
        public static bool Update(MenuItemModel menuItem)
        {
            try
            {
                if (menuItem.ItemID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblMenuItem TblMenuItem = rc.TblMenuItems.FirstOrDefault(u => u.ItemID == menuItem.ItemID);

                        if (TblMenuItem != null)
                        {
                            TblMenuItem.ItemID        = menuItem.ItemID;
                            TblMenuItem.ItemName      = menuItem.ItemName;
                            TblMenuItem.Picture       = menuItem.Picture;
                            TblMenuItem.Price         = menuItem.Price;
                            TblMenuItem.Description   = menuItem.Description;
                            TblMenuItem.MenuSectionID = menuItem.MenuSectionID;
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Item was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 27
0
        public static bool Update(OrderItemModel orderItem)
        {
            try
            {
                if (orderItem.OrderItemID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblOrderItem tblOrderItem = rc.TblOrderItems.FirstOrDefault(u => u.OrderItemID == orderItem.OrderItemID);

                        if (tblOrderItem != null)
                        {
                            tblOrderItem.OrderItemID = orderItem.OrderItemID;
                            tblOrderItem.Price       = orderItem.Price;
                            tblOrderItem.MenuItemId  = orderItem.MenuItemID;
                            tblOrderItem.Quantity    = orderItem.Quantity;


                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Item was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 28
0
        public static bool Update(UserModel user)
        {
            try
            {
                if (user.UserID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblUser tblUser = rc.TblUsers.FirstOrDefault(u => u.UserID == user.UserID);

                        if (tblUser != null)
                        {
                            tblUser.Phone     = user.Phone;
                            tblUser.Email     = user.Email;
                            tblUser.FirstName = user.FirstName;
                            tblUser.LastName  = user.LastName;
                            tblUser.Admin     = user.Admin;
                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("User was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 29
0
 public static bool Insert(OrderItemModel orderItem)
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblOrderItem newRow = new TblOrderItem()
             {
                 OrderItemID = rc.TblOrderItems.Any() ? rc.TblOrderItems.Max(u => u.OrderItemID) + 1 : 1,
                 OrderID     = orderItem.OrderID,
                 MenuItemId  = orderItem.MenuItemID,
                 Price       = orderItem.Price,
                 Quantity    = orderItem.Quantity
             };
             rc.TblOrderItems.Add(newRow);
             rc.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static bool Update(VendorLocationModel vendorLocation)
        {
            try
            {
                if (vendorLocation.VendorID != 0)
                {
                    using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
                    {
                        TblVendorLocation tblVendorLocation = rc.TblVendorLocations.FirstOrDefault(v => v.VendorID == vendorLocation.VendorID);

                        if (tblVendorLocation != null)
                        {
                            tblVendorLocation.VendorID  = vendorLocation.VendorID;
                            tblVendorLocation.LocationX = vendorLocation.LocationX;
                            tblVendorLocation.LocationY = vendorLocation.LocationY;
                            tblVendorLocation.Datetime  = vendorLocation.Date;

                            rc.SaveChanges();
                            return(true);
                        }
                        else
                        {
                            throw new Exception("Vendor was not found");
                        }
                    }
                }
                else
                {
                    throw new Exception("Must have a valid id");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }