Exemplo n.º 1
0
        public async Task <CheckStatusModel> CheckStatus(string Name, string Url)
        {
            var result = await(from cr in _context.CheckRegister
                               join crun in _context.CheckRun
                               on cr.Id equals crun.CheckRegister.Id
                               where cr.Name == Name && cr.Url == Url
                               orderby crun.LastRunOn descending
                               select new{ Status    = crun.Status,
                                           RunTime   = TimeSpan.Parse(crun.RunTime),
                                           LastRunOn = crun.LastRunOn }).ToListAsync();

            var checkStatus = new CheckStatusModel();

            if (result.Any())
            {
                var lastRun = result.Where(x => x.Status != result.FirstOrDefault().Status).FirstOrDefault();
                checkStatus.Name        = Name;
                checkStatus.Url         = Url;
                checkStatus.Status      = result.FirstOrDefault().Status;
                checkStatus.StatusSince = lastRun == null?result.FirstOrDefault().LastRunOn : lastRun.LastRunOn;

                checkStatus.AveragResoponseTime = result.Average(x => x.RunTime.TotalMilliseconds).ToString();
            }

            return(checkStatus);
        }
Exemplo n.º 2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            var Chuu2 = new CheckStatusModel();

            using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection()))
            {
                Rikka.Open();
                string Takanashi = @"SELECT r.RSG_CheckStatID, r.RSG_RID, res.RSG_RName, res.RSG_Image, res.RSG_RName, u.RSG_Username, 
                               res.RSG_Address, res.RSG_ContactNumber, res.RSG_Branch,
                               res.RSG_OperatingHours,res.RSG_TotalSeats, c.RSG_Category FROM RSG_CheckStat r 
							   INNER JOIN RSG_Restaurants res ON r.RSG_RID = res.RSG_RID
                               INNER JOIN RSG_Categories c ON res.RSG_CatID = c.RSG_CatID
                               INNER JOIN RSG_Users u ON r.RSG_UserID = u.RSG_UserID 
                               WHERE r.RSG_RID = @RID";



                using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka))
                {
                    WickedEye.Parameters.AddWithValue("@RID", id);
                    using (SqlDataReader Nibutani = WickedEye.ExecuteReader())
                    {
                        if (Nibutani.HasRows)
                        {
                            while (Nibutani.Read())
                            {
                                Chuu2.RestaurantID   = int.Parse(Nibutani["RSG_RID"].ToString());
                                Chuu2.RestaurantName = Nibutani["RSG_RName"].ToString();
                                Chuu2.Address        = Nibutani["RSG_Address"].ToString();
                                Chuu2.Image          = Nibutani["RSG_Image"].ToString();
                                Chuu2.Branch         = Nibutani["RSG_Branch"].ToString();
                                Chuu2.ContactNumber  = Nibutani["RSG_ContactNumber"].ToString();
                                Chuu2.Owner          = Nibutani["RSG_Username"].ToString();
                                Chuu2.TotalSeats     = Nibutani["RSG_TotalSeats"].ToString();
                                Chuu2.OperatingHours = Nibutani["RSG_OperatingHours"].ToString();
                                Chuu2.Category       = Nibutani["RSG_Category"].ToString();
                                Chuu2.CheckStatusID  = int.Parse(Nibutani["RSG_CheckStatID"].ToString());
                            }


                            ViewBag.Total = (GetTotalCheckIns(id).ToString());

                            return(View(Chuu2));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public async Task <bool> CheckBusinessID(Guid businessID)
        {
            var businessId = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);

            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from checkbusinessid(@thebusinessid) as checkbusinessid", businessId)
                                                               .Select(e => new CheckStatusModel()
            {
                BusinessIDStatus = e.BusinessIDStatus
            }).FirstOrDefault());

            return(checkStatusModel.BusinessIDStatus);
        }
Exemplo n.º 4
0
        public async Task <bool> ActivateUserById(Guid userID)
        {
            var userId = new Npgsql.NpgsqlParameter("@theuserid", userID);

            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from activateuser(@theuserid)", userId)
                                                               .Select(e => new CheckStatusModel()
            {
                Status = e.Status
            }).FirstOrDefault());

            return(checkStatusModel.Status);
        }
Exemplo n.º 5
0
        public async Task <bool> ActivateEmployeeById(Guid BusinessID, Guid employeeId)
        {
            var businessID = new Npgsql.NpgsqlParameter("@thebusinessid", BusinessID);
            var employeeID = new Npgsql.NpgsqlParameter("@theempid", employeeId);

            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from activateemployeebyid(@thebusinessid,@theempid)", businessID, employeeID)
                                                               .Select(e => new CheckStatusModel()
            {
                Status = e.Status
            }).FirstOrDefault());

            return(checkStatusModel.Status);
        }
Exemplo n.º 6
0
        public async Task <bool> CheckIfEmployeeHasAlreaySaleryAssigned(Guid businessID, Guid employeeID)
        {
            var businessId = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);
            var employeeId = new Npgsql.NpgsqlParameter("@theempid", employeeID);


            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from checkemployeeidhavingsaleryassigned(@thebusinessid,@theempid) as checkemployeeid", businessId, employeeId)
                                                               .Select(e => new CheckStatusModel()
            {
                EmployeeIDStatus = e.EmployeeIDStatus
            }).FirstOrDefault());

            return(checkStatusModel.EmployeeIDStatus);
        }
Exemplo n.º 7
0
        public async Task <bool> ActivateBusinessUserById(Guid businessID, Guid businesUserID)
        {
            var businessId    = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);
            var businesUserId = new Npgsql.NpgsqlParameter("@thebuid", businesUserID);


            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from activatebusinessuser(@thebusinessid,@thebuid) as status", businessId, businesUserId)
                                                               .Select(e => new CheckStatusModel()
            {
                Status = e.Status
            }).FirstOrDefault());

            return(checkStatusModel.Status);
        }
Exemplo n.º 8
0
        public async Task <bool> CheckDeductionID(Guid businessID, Guid deductionID)
        {
            var businessId  = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);
            var deductionId = new Npgsql.NpgsqlParameter("@thedeductionid", deductionID);


            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from checkdeductionid(@thebusinessid,@thedeductionid)", businessId, deductionId)
                                                               .Select(e => new CheckStatusModel()
            {
                DeductionIDStatus = e.DeductionIDStatus
            }).FirstOrDefault());

            return(checkStatusModel.DeductionIDStatus);
        }
Exemplo n.º 9
0
        public async Task <bool> CheckIncrementID(Guid businessID, Guid incrementID)
        {
            var businessId  = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);
            var incrementId = new Npgsql.NpgsqlParameter("@theincrementid", incrementID);


            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from checkincrementid(@thebusinessid,@theincrementid) ", businessId, incrementId)
                                                               .Select(e => new CheckStatusModel()
            {
                IncrementIDStatus = e.IncrementIDStatus
            }).FirstOrDefault());

            return(checkStatusModel.IncrementIDStatus);
        }
Exemplo n.º 10
0
        public async Task <bool> UpdateEmployeeSalaryBySalaryID(Guid businessID, Guid SalaryID, UpdateSalaryModel updateSalaryModel)
        {
            var businessId = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);
            var salaryId   = new Npgsql.NpgsqlParameter("@thesalaryid", SalaryID);
            var salary     = new Npgsql.NpgsqlParameter("@thesalary", updateSalaryModel.Salary);

            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from updatesalarybyid(@thebusinessid,@thesalaryid," +
                                                                                                                   "@thesalary) as salaryupdatastatus", businessId, salaryId, salary)
                                                               .Select(e => new CheckStatusModel()
            {
                salaryUpdateStatus = e.salaryUpdateStatus
            }).FirstOrDefault());

            return(checkStatusModel.salaryUpdateStatus);
        }
Exemplo n.º 11
0
        public async Task <bool> AddEmployeeSalary(Guid businessID, SalaryModel salaryModel)
        {
            var businessId = new Npgsql.NpgsqlParameter("@thebusinessid", businessID);
            var employeeId = new Npgsql.NpgsqlParameter("@theempid", salaryModel.EmployeeID);
            var salary     = new Npgsql.NpgsqlParameter("@thesalary", salaryModel.Salary);

            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from addsalary(@thebusinessid,@theempid," +
                                                                                                                   "@thesalary)", businessId, employeeId, salary)
                                                               .Select(e => new CheckStatusModel()
            {
                Status = e.Status
            }).FirstOrDefault());

            return(checkStatusModel.Status);
        }
Exemplo n.º 12
0
        public async Task <bool> UpdateUserById(Guid userID, UserModel userModel)
        {
            var userId      = new Npgsql.NpgsqlParameter("@theuserid", userID);
            var userName    = new Npgsql.NpgsqlParameter("@theusername", userModel.UserName);
            var userFName   = new Npgsql.NpgsqlParameter("@thefirstname", userModel.UserFirstName);
            var userLName   = new Npgsql.NpgsqlParameter("@thelastname", userModel.UserLastName);
            var userEmail   = new Npgsql.NpgsqlParameter("@theuseremail", userModel.UserEmail);
            var userContact = new Npgsql.NpgsqlParameter("@thecontact", userModel.UserContact);

            CheckStatusModel checkStatusModel = await Task.Run(() => _projectContextDB.CheckStatusModel.FromSqlRaw("select * from updateuser(@theuserid,@theusername," +
                                                                                                                   "@thefirstname,@thelastname,@theuseremail,@thecontact)", userId, userName, userFName, userLName, userEmail, userContact)
                                                               .Select(e => new CheckStatusModel()
            {
                Status = e.Status
            }).FirstOrDefault());

            return(checkStatusModel.Status);
        }