예제 #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 bool CheckIfExists(BOL.Models.Task task)
        {
            string query = $"SELECT * FROM task.task WHERE idProject={task.IdProject} and idUser={task.IdUser};";
            List <BOL.Models.Task> projects = new List <BOL.Models.Task>();
            Func <MySqlDataReader, List <BOL.Models.Task> > func = (reader) =>
            {
                List <BOL.Models.Task> projectsWorker = new List <BOL.Models.Task>();
                while (reader.Read())
                {
                    projectsWorker.Add(ConvertorTask.convertToTask(reader));
                }
                return(projectsWorker);
            };

            List <BOL.Models.Task> ProjectWorker = DBAccess.RunReader(query, func);

            if (ProjectWorker != null && ProjectWorker.Count > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        public static bool AddTask(BOL.Models.Task task)
        {
            string query = $"INSERT INTO `task`.`task`(`reservingHours`,`givenHours`,`idProject`,`idUser`)VALUES({task.ReservingHours},{task.GivenHours },{task.IdProject},{task.IdUser});";

            return(DBAccess.RunNonQuery(query) == 1);
        }
예제 #4
0
        public static bool UpdateTask(BOL.Models.Task task)
        {
            string query = $"UPDATE `task`.`task` SET `reservingHours` = {task.ReservingHours},`givenHours` = {task.GivenHours} WHERE `idTask` = {task.IdTask};";

            return(DBAccess.RunNonQuery(query) == 1);
        }