Пример #1
0
        public static bool UpdatePresent(PresentDay presentDay)
        {
            PresentDay currentPresentDay = GetPresentById(presentDay.IdPresentDay);
            TimeSpan   t = DateTime.Parse(presentDay.TimeEnd.ToString("yyyy-MM-dd HH:mm:ss")) - currentPresentDay.TimeBegin;

            double addedHours = t.TotalHours;

            string query = $"UPDATE task.PresentDay SET EndHour='{presentDay.TimeEnd.ToString("yyyy-MM-dd HH:mm:ss")}',TotalHours={addedHours} WHERE IdPresentDay={presentDay.IdPresentDay}";

            if (DBAccess.RunNonQuery(query) == 1)
            {
                BOL.Models.Task currentTask = LogicTask.GetTaskByIdProjectAndIdUser(currentPresentDay.UserId, currentPresentDay.ProjectId);
                currentTask.GivenHours += (decimal)addedHours;
                if (LogicTask.UpdateTask(currentTask))
                {
                    User Currentuser = LogicManager.GetUserDetails(currentPresentDay.UserId);
                    Currentuser.NumHoursWork += (decimal)addedHours;
                    if (LogicManager.UpdateUser(Currentuser))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #2
0
        public static void CheckDeadLine()
        {
            List <Project> deadProjects = new List <Project>();

            deadProjects = GetAllProjectsByDeadLine();
            foreach (Project proj in deadProjects)
            {
                User teamHead = new User();
                teamHead = LogicManager.GetUserDetails(proj.IdManager);
                List <User> workers = new List <User>();
                workers = LogicManager.GetAllWorkersByTeamId(proj.IdManager);
                LogicManager.sendMessage(teamHead, $"Hi {teamHead.UserName}, <br/>Project: {proj.ProjectName} is about to reach the deadline tomorrow. This project is under your responsibility, please hurry up!!!", "ATTENTION");
                foreach (User worker in workers)
                {
                    LogicManager.sendMessage(worker, $"Hi {worker.UserName}, <br/>Project: {proj.ProjectName} is about to reach the deadline tomorrow. you are subscribed to this project, please hurry up!!!", "ATTENTION");
                }
            }
        }