示例#1
0
        public bool AddTask(TasksMobileDto tasksMobileDto)
        {
            if (_taskRepositories.Get(tasksMobileDto.Name) != null)
            {
                return(false);
            }
            var tmp = new TaskDto()
            {
                Name        = tasksMobileDto.Name,
                Type        = tasksMobileDto.Type,
                Activities  = new List <ActivityDto>(),
                Description = "",
                Favorites   = new List <FavoritesDto>()
            };

            _taskRepositories.Add(tmp);
            return(true);
        }
示例#2
0
        public bool AddFavorites(FavoritesMobileDto favoritesMobileDto)
        {
            TaskDto tmpTask = null;

            try
            {
                try
                {
                    tmpTask = _taskRepositories.Get(favoritesMobileDto.Task.Name);
                }
                catch (Exception e)
                {
                }

                if (tmpTask == null)
                {
                    tmpTask = new TaskDto()
                    {
                        Description = "",
                        Name        = favoritesMobileDto.Task.Name,
                        Activities  = new List <ActivityDto>(),
                        Favorites   = new List <FavoritesDto>(),
                        Type        = ""
                    };

                    _taskRepositories.Add(tmpTask);
                }
                var fav = new FavoritesDto()
                {
                    Task = _taskRepositories.Get(tmpTask.Name),
                    User = _userRepositories.Get(favoritesMobileDto.UserEmail)
                };
                _favoritesRepositories.Add(fav);
            }
            catch (Exception e)
            {
                return(false);
            }


            return(true);
        }
示例#3
0
        public bool AddActivity(ActivityMobileDto activityMobileDto)
        {
            if (activityMobileDto.State == State.Planned)
            {
                return(false);
            }
            TaskDto tmpTask = null;
            int     idAct;

            try
            {
                tmpTask = _taskRepositories.Get(activityMobileDto.TaskName);
            }
            catch (Exception e)
            {
            }

            if (tmpTask == null)
            {
                tmpTask = new TaskDto()
                {
                    Description = "",
                    Name        = activityMobileDto.TaskName,
                    Activities  = new List <ActivityDto>(),
                    Favorites   = new List <FavoritesDto>(),
                    Type        = ""
                };
                _taskRepositories.Add(tmpTask);
            }
            var tmpActivity = new ActivityDto
            {
                Comment         = activityMobileDto.Comment,
                Guid            = activityMobileDto.Guid,
                State           = activityMobileDto.State,
                EditState       = activityMobileDto.EditState,
                User            = _userRepositories.Get(activityMobileDto.UserEmail),
                Task            = _taskRepositories.Get(activityMobileDto.TaskName),
                Group           = _groupRepositories.Get(1),
                PartsOfActivity = new List <PartsOfActivityDto>()
            };

            try
            {
                idAct = _activityRepositories.Add(tmpActivity);
            }
            catch (Exception)
            {
                return(false);
            }
            foreach (var part in activityMobileDto.TaskPartsList)
            {
                var tmpPart = new PartsOfActivityDto
                {
                    Start    = DateTime.ParseExact(part.Start, "HH:mm:ss dd/MM/yyyy", CultureInfo.InvariantCulture),
                    Stop     = DateTime.ParseExact(part.Start, "HH:mm:ss dd/MM/yyyy", CultureInfo.InvariantCulture),
                    Duration = TimeSpan.ParseExact(part.Duration, "G", CultureInfo.InvariantCulture),
                    Activity = _activityRepositories.Get(idAct)
                };
                try
                {
                    _partsOfActivityRepositories.Add(tmpPart);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(true);
        }
        public bool AddPlanned(PlannedMobileDto plannedMobileDto)
        {
            if (plannedMobileDto.State != State.Planned)
            {
                return(false);
            }
            TaskDto tmpTask = null;
            int     idAct;

            try
            {
                tmpTask = _taskRepositories.Get(plannedMobileDto.TaskName);
            }
            catch (Exception e)
            {
            }

            if (tmpTask == null)
            {
                tmpTask = new TaskDto()
                {
                    Description = "",
                    Name        = plannedMobileDto.TaskName,
                };
                _taskRepositories.Add(tmpTask);
            }
            var tmpActivity = new ActivityDto
            {
                Comment   = plannedMobileDto.Comment,
                Guid      = plannedMobileDto.Guid,
                State     = plannedMobileDto.State,
                EditState = plannedMobileDto.EditState,
                User      = _userRepositories.Get(plannedMobileDto.UserEmail),
                Task      = _taskRepositories.Get(plannedMobileDto.TaskName),
                Group     = _groupRepositories.Get(1)
            };

            try
            {
                idAct = _activityRepositories.Add(tmpActivity);
            }
            catch (Exception)
            {
                return(false);
            }

            try
            {
                var tmpPart = new PartsOfActivityDto
                {
                    Start    = DateTime.ParseExact(plannedMobileDto.TaskPart.Start, "HH:mm:ss dd/MM/yyyy", CultureInfo.InvariantCulture),
                    Stop     = DateTime.MaxValue,
                    Duration = TimeSpan.Zero,
                    Activity = _activityRepositories.Get(idAct)
                };
                _partsOfActivityRepositories.Add(tmpPart);
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }