Example #1
0
        public static int CreateRoommate(string firstName, string lastName, decimal payment)
        {
            RoommateModel data = new RoommateModel
            {
                FirstName      = firstName,
                LastName       = lastName,
                MonthlyPayment = (decimal)CalculatePayment()
            };
            //string sql = @"insert into dbo.Roommates (FirstName, LastName)
            //                Values(@FirstName, @LastName);";


            string sql = $"sp_AddRoommate '{data.FirstName}','{data.LastName}', '{data.MonthlyPayment}'";

            return(SqlDataAccess.SaveData <RoommateModel>(sql, data));
        }
Example #2
0
        public static int UpdateManuscript(int id, string type, string value)
        {
            var sql = @"UPDATE library_item " +
                      $"SET {type} = @Value " +
                      "WHERE id = @Id " +
                      "AND Category = 'manuscript'";

            var data = new DynamicUpdateModel
            {
                Id    = id,
                Type  = type,
                Value = value
            };

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #3
0
        public static int PutInCompany(string id, string businessName, string phoneNumber, string description, int zipcode)
        {
            Company data = new Company
            {
                AccountId    = id,
                BusinessName = businessName,
                PhoneNumber  = phoneNumber,
                Description  = description,
                Zipcode      = zipcode
            };

            string sql = @"INSERT INTO dbo.Companies (AccountId, BusinessName, PhoneNumber, Description, Zipcode) 
                            VALUES (@AccountId, @BusinessName, @PhoneNumber, @Description, @Zipcode);";

            return(SqlDataAccess.SaveData(sql, data));     //goes to the Sql DataAccess class
        }
Example #4
0
        public static int CreateOrder(int id, string name, string description, string ingredients, float price)
        {
            OrderModel data = new OrderModel
            {
                Id          = id,
                Name        = name,
                Description = description,
                Ingredients = ingredients,
                Price       = price
            };

            string sql = @"insert into dbo.OrderQueue (Id, Name, Description, Ingredients, Price)
                            values (@Id, @Name, @Description, @Ingredients, @Price);";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public static int CreateOrganization(int organizationId, string organizationName, string organizationEmail)
        {
            OrganizationModel data = new OrganizationModel
            {
                OrganizationId    = organizationId,
                OrganizationName  = organizationName,
                OrganizationEmail = organizationEmail
            };

            // @ tells it it's a variable.  it's teh data you're paassign with the statment.
            // e.g @ModuleId's value is going to be stored in moduleId
            string sql = @"insert into dbo.Organization (OrganizationId, OrganizationName, OrganizationEmail)
                            values (@OrganizationId, @OrganizationName, @OrganizationEmail);";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public static int WriteAuthenticationToken(int userId, string token)
        {
            var          date = DateTime.Now.AddHours(24);
            const string sql  = @"INSERT INTO authentication_token(UserId, Token, ExpireDateTime) VALUES(@UserId, @Token, @ExpireDateTime);";

            var data = new TokenModel
            {
                Token          = token,
                UserId         = userId,
                ExpireDateTime = date.ToString("yyyy-MM-dd hh:mm:ss")
            };

            SqlDataAccess.SaveData(sql, data);

            return(UserProcessor.GetUserRole(token));
        }
        public static int CreateItem(int drinkId, string name, string description, string ingredients, float price)
        {
            ItemModel data = new ItemModel
            {
                DrinkId     = drinkId,
                Name        = name,
                Description = description,
                Ingredients = ingredients,
                Price       = price
            };

            string sql = @"insert into dbo.MenuTable (DrinkId, Name, Description, Ingredients, Price)
                            values (@DrinkId, @Name, @Description, @Ingredients, @Price);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #8
0
        public static int CreateBill(string billName, decimal amount, DateTime duedate)
        {
            BillModel data = new BillModel
            {
                BillName  = billName,
                AmountDue = amount,
                DueDate   = duedate,
                IsCurrent = true
            };

            string sql = $"sp_AddNewBill '{data.BillName}', '{data.AmountDue}', '{data.DueDate}'";

            UpdatePayments(data.AmountDue);
            //TODO (CAN I REMOVE THIS YET)impliment this AssignedBillProcessor.AssignBill(data, roommate);
            return(SqlDataAccess.SaveData(sql, data));
        }
        public static int EditEmployee(int employeeId, string firstName, string lastName, string emailAddress)
        {
            EmployeeModel data = new EmployeeModel
            {
                EmployeeId   = employeeId,
                FirstName    = firstName,
                LastName     = lastName,
                EmailAddress = emailAddress
            };

            string sql = @"UPDATE dbo.Employees
                            SET FirstName = @FirstName, LastName = @LastName, EmailAddress = @EmailAddress
                            WHERE EmployeeId = @EmployeeId";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #10
0
        public static int RegisterUser(UserModel userModel)
        {
            var sql = @"INSERT INTO user(UserName, Email, Pass) " +
                      $"VALUES(@Username, @Email, @Pass)";

            var model = new UserModel
            {
                UserName = userModel.UserName,
                Email    = userModel.Email,
                Pass     = Hashing.HashPassword(userModel.Pass),
                UserType = userModel.UserType
            };


            return(SqlDataAccess.SaveData(sql, model));
        }
        public static int CreateEmployee(int employeeId, string firstName, string lastName,
                                         string emailAddress)
        {
            EmployeeModel data = new EmployeeModel
            {
                EmployeeId   = employeeId,
                FirstName    = firstName,
                LastName     = lastName,
                EmailAddress = emailAddress
            };

            string sql = @"insert into dbo.Employee (EmployeeId, FirstName, LastName, EmailAddress) 
                        values (@EmployeeId, @FirstName, @LastName, @EmailAddress);";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public static int CreateEmployee(int employeeId, string firstName, string lastName, string emailId, string password)
        {
            Employee data = new Employee
            {
                EmployeeId = employeeId,
                FirstName  = firstName,
                LastName   = lastName,
                Email_Id   = emailId,
                Password   = password
            };

            string sql = @"insert into dbo.Employee(EmployeeId, FirstName, LastName, Email_Id, Password)
                           values (@EmployeeId, @FirstName, @LastName, @Email_Id, @Password);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #13
0
        public static int CreateEmployee(string firstName, string lastName, DateTime?dob, string email, string address,
                                         string phoneNumber)
        {
            EmployeeModel data = new EmployeeModel
            {
                FirstName    = firstName,
                LastName     = lastName,
                DateofBirth  = dob,
                EmailAddress = email,
                Address      = address,
                PhoneNumber  = phoneNumber
            };
            string sql = @"insert into dbo.Employee(FirstName, LastName, DateofBirth, EmailAddress, Address, PhoneNumber )
                           values (@FirstName,@LastName,@DateofBirth,@EmailAddress,@Address,@PhoneNumber);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #14
0
        public static int CreateEmployee(int employeeId, string firstName, string lastName, string emailAddress)
        {
            EmployeeModel data = new EmployeeModel
            {
                EmployeeId   = employeeId,
                FirstName    = firstName,
                LastName     = lastName,
                EmailAddress = emailAddress
            };

            string sql = @"INSERT INTO [dbo].[Employee] 
                            ([EmployeeId], [FirstName], [LastName], [EmailAddress]) 
                            VALUES 
                            (@EmployeeId, @FirstName, @LastName, @EmailAddress)";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #15
0
        //method to create Users
        public static int CreateUsers(string userName, string firstName, string lastName)
        {
            //organize the data that will be added
            UserModel data = new UserModel
            {
                UserName  = userName,
                FirstName = firstName,
                LastName  = lastName
            };

            //create an sql query to create the new User
            string sql = @"insert into dbo.[User] (UserName, FirstName, LastName)
                            values (@UserName, @FirstName, @LastName)";

            //call the sqlDataAccess to create the new User
            return(SqlDataAccess.SaveData(sql, data));
        }
Example #16
0
        public static int updateOrder(int orderId, int partId, string projectName, DateTime lastMaterialDate, DateTime shipDate, int quantity, string status, int priority)
        {
            orderModel data = new orderModel
            {
                orderId          = orderId,
                partId           = partId,
                projectName      = projectName,
                lastMaterialDate = lastMaterialDate,
                shipDate         = shipDate,
                quantity         = quantity,
                status           = status,
                priority         = priority
            };
            string sql = @"update [Order] set partId=@partId,projectName=@projectName,lastMaterialDate=@lastMaterialDate,shipDate=@shipDate,quantity=@quantity, status=@status,priority=@priority where orderId=@orderId ;";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #17
0
        public static int CreateOrder(int orderId, int partId, string projectName, DateTime lastMaterialDate,
                                      DateTime shipDate, int quantity)
        {
            orderModel data = new orderModel
            {
                orderId          = orderId,
                partId           = partId,
                projectName      = projectName,
                lastMaterialDate = lastMaterialDate,
                shipDate         = shipDate,
                quantity         = quantity
            };
            string sql = @"insert into [Order] (orderId,partId,projectName,lastMaterialDate,shipDate,quantity)
                            values (@orderId,@partId,@projectName,CONVERT(datetime,@lastMaterialDate,104),CONVERT(datetime,@shipDate,104),@quantity);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #18
0
        public static int UpdateElementCard(string elementType, string elementName, int inSan, int deSan, string isForce, string isInter, string elementDes)
        {
            ElementModels data = new ElementModels

            {
                ElementType = elementType,
                InSan       = inSan,
                DeSan       = deSan,
                IsForce     = isForce,
                IsInter     = isInter,
                ElementDes  = elementDes,
            };

            string sql = @"UPDATE dbo.CardTBL SET ElementType = @ElementType,InSan=@InSan,DeSan=@DeSan,IsForce=@IsForce,IsInter=@IsInter,ElementDes=@ElementDes WHERE ElementName= '" + elementName + "'";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #19
0
        public static int CreateUser(string firstName, string lastName, string emailAddress, string password, DateTime birthday, string gender)
        {
            UserModels data = new UserModels
            {
                FirstName    = firstName,
                LastName     = lastName,
                EmailAddress = emailAddress,
                Password     = password,
                BirthDay     = birthday,
                Gender       = gender
            };

            string sql = @"INSERT INTO dbo.[User] (FirstName, LastName, EmailAddress, Password, BirthDay, Gender)
                            VALUES (@FirstName, @LastName, @EmailAddress, @Password, @BirthDay, @Gender)";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #20
0
        public static int CreateComenzi(string town, string address, int number, string phoneNumber, DateTime date, int customerId)
        {
            OrderModel data = new OrderModel
            {
                Town        = town,
                Address     = address,
                Number      = number,
                PhoneNumber = phoneNumber,
                Date        = date,
                CustomerId  = customerId
            };

            string sql = @"insert into dbo.Comanda (Town, Address, Number, PhoneNumber, Date, CustomerId)
                         values (@Town, @Address, @Number, @PhoneNumber, @Date, @CustomerId);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #21
0
        public static int AddProduct(string name, float calories, float proteins,
                                     float carbohydrates, float fats)
        {
            ProductsModel data = new ProductsModel
            {
                Name          = name,
                Calories      = calories,
                Proteins      = proteins,
                Carbohydrates = carbohydrates,
                Fats          = fats
            };

            string sql = @"INSERT INTO Products (name, calories, proteins, carbohydrates, fats)
            values(@Name, @Calories, @Proteins, @Carbohydrates, @Fats);";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public static int CreateCourse(int courseId, string courseName,
                                       string courseQualification, int courseResult, int courseLength)
        {
            CourseModel data = new CourseModel
            {
                CourseId            = courseId,
                CourseName          = courseName,
                CourseQualification = courseQualification,
                CourseResult        = courseResult,
                CourseLength        = courseLength
            };

            string sql = @"insert into dbo.Course (CourseId, CourseName, CourseQualification, CourseResult, CourseLength)
                            values (@CourseId, @CourseName, @CourseQualification, @CourseResult, @CourseLength);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #23
0
        public static int CreateEmployee(int employeeId, string role, string lastName, string firstName, string city, string country, string email)
        {
            EmployeeModel data = new EmployeeModel
            {
                EmployeeId = employeeId,
                Role       = role,
                LastName   = lastName,
                FirstName  = firstName,
                City       = city,
                Country    = country,
                Email      = email
            };

            string sql = @"insert into dbo.Employee (EmployeeId, Role, LastName, FirstName, City, Country, Email) values (@EmployeeId, @Role, @LastName, @FirstName, @City, @Country, @Email);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #24
0
        //create new Store
        public static int CreateStore(int storeId, string storeName, string storeAddress, string phoneNumber,
                                      string hoursOfOperation)
        {
            StoreModel data = new StoreModel
            {
                StoreId          = storeId,
                StoreName        = storeName,
                StoreAddress     = storeAddress,
                PhoneNumber      = phoneNumber,
                HoursOfOperation = hoursOfOperation
            };

            string sql = @"Insert into dbo.[Store]( StoreName, StoreAddress, PhoneNumber, HoursOfOperation)
                           Values ( @StoreName, @StoreAddress, @PhoneNumber, @HoursOfOperation);";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #25
0
        public static int SaveEditedProduct(int?id, string productName, int categoryId, string description, int price, string urlLink)
        {
            ProductModel data = new ProductModel
            {
                ProductId    = id,
                ProductName  = productName,
                CategoryId   = categoryId,
                Description  = description,
                ProductPrice = price,
                UrlLink      = urlLink
            };

            string sql = @"update dbo.Products set ProductName=@ProductName,CategoryId=@CategoryId, Description=@Description,
            ProductPrice=@ProductPrice, UrlLink=@UrlLink where Id_Product=@ProductId ";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #26
0
        public static int SetBook(ItemModel itemModel)
        {
            var sql = $@"INSERT INTO library_item(Title, Description, Author, PublishYear, Category, Access) " +
                      "VALUES(@Title, @Description, @Author, @PublishYear, @Category, @Access)";

            var model = new ItemModel
            {
                Title       = itemModel.Title,
                Description = itemModel.Description,
                Author      = itemModel.Author,
                PublishYear = itemModel.PublishYear,
                Category    = itemModel.Category,
                Access      = itemModel.Access
            };

            return(SqlDataAccess.SaveData(sql, model));
        }
        public static int CreateReview(string Category, string BookName, string ReviewType, string BookSubject, string BookAnalysis, string AuthorName, string OtherBooks)
        {
            ReviewModel data = new ReviewModel
            {
                Category     = Category,
                BookName     = BookName,
                ReviewType   = ReviewType,
                BookSubject  = BookSubject,
                BookAnalysis = BookAnalysis,
                AuthorName   = AuthorName,
                OtherBooks   = OtherBooks
            };
            string sql = @"INSERT INTO dbo.Review(Category, BookName, ReviewType, BookSubject, BookAnalysis, AuthorName, OtherBooks) 
				VALUES(@Category, @BookName, @ReviewType, @BookSubject, @BookAnalysis, @AuthorName, @OtherBooks);"                ;

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #28
0
        public static int CreateUpload(string creatorName, string taskName, string fileName, string mimeType,
                                       string base64String, DateTime dateCreated)
        {
            UploadModel data = new UploadModel
            {
                CreatorName  = creatorName,
                TaskName     = taskName,
                FileName     = fileName,
                MimeType     = mimeType,
                Base64String = base64String,
                DateCreated  = dateCreated
            };

            string sql = @"insert into dbo.FileTable(CreatorName, TaskName, FileName, MimeType, Base64String, DateCreated)
                           values (@CreatorName, @TaskName, @FileName, @MimeType, @Base64String, @DateCreated);";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public static int CreateAuction(string title, string description, string startTime, string endTime, int totalProducts, string status, string mainPic)
        {
            AuctionEventModel data = new AuctionEventModel
            {
                auctionTitle       = title,
                auctionDescription = description,
                StartTime          = startTime,
                EndTime            = endTime,
                totalProduct       = totalProducts,
                auctionStatus      = status,
                auctionMainPicture = mainPic
            };

            string sql = @"INSERT INTO dbo.AuctionEvent (AuctionTitle, Description, StartTime, EndTime, TotalProducts, AuctionStatus, AuctionMainPicture)
                VALUES(@title, @description, @startTime, @endTime, @totalProducts, @status, @mainPic)";

            return(SqlDataAccess.SaveData(sql, data));
        }
Example #30
0
        public static int CreateUsers(int user_ID, string userName, string firstName,
                                      string lastName, string middleName, string emailAddress, string userPassword)
        {
            UsersModel data = new UsersModel
            {
                User_ID      = user_ID,
                UserName     = userName,
                FirstName    = firstName,
                LastName     = lastName,
                MiddleName   = middleName,
                EmailAddress = emailAddress,
                UserPassword = userPassword
            };

            string sql = @"insert into dbo.UserInfo (User_ID, UserName, FirstName, LastName, MiddleName, EmailAddress, UserPassword) values (@User_ID, @UserName, @FirstName, @LastName, @MiddleName, @EmailAddress, @UserPassword);";

            return(SqlDataAccess.SaveData(sql, data));
        }