Exemplo n.º 1
0
        /// <summary>
        /// Creates a TaskItemDAL from a TaskItem and CreateTaskInput
        /// </summary>
        /// <param name="taskItem">
        /// Will have its data used to create a TaskItemDAL
        /// </param>
        /// <param name="input">
        /// </param>
        /// <returns>
        /// TaskItemDAL created from the data of the taskItem parameter
        /// </returns>

        /*
         * TODO: this should probably end up in a conversion class, of some sort, in the application
         * layer
         */
        private TaskItemDAL TaskItemAndInputToDAL(TaskItem taskItem, CreateTaskInput input)
        {
            Maybe <CustomNotificationFrequencyDAL> notificationFrequency = Maybe <CustomNotificationFrequencyDAL> .CreateEmpty();

            //if the new task should have a custom notification frequency
            if (input.NotificationFrequencyType == NotificationFrequencyType.Custom)
            {
                //create a custom notification frequency DAL
                notificationFrequency = Maybe <CustomNotificationFrequencyDAL> .Create(
                    new CustomNotificationFrequencyDAL(
                        taskItem.ID,
                        input.CustomNotificationFrequency
                        )
                    );
            }

            return(new TaskItemDAL(
                       taskItem.ID,
                       taskItem.Title,
                       taskItem.Description,
                       taskItem.StartTime,
                       taskItem.LastNotificationTime,
                       taskItem.Colour.R,
                       taskItem.Colour.G,
                       taskItem.Colour.B,
                       notificationFrequency,
                       (int)input.NotificationFrequencyType
                       ));
        }
        public Maybe <CustomNotificationFrequencyDAL> GetById(Guid id)
        {
            var findByIdQuery = GetQueryForId(id);

            if (findByIdQuery.Count() != 1)
            {
                return(Maybe <CustomNotificationFrequencyDAL> .CreateEmpty());
            }
            else
            {
                return
                    (Maybe <CustomNotificationFrequencyDAL> .Create(
                         DataRowToNotificationFrequencyDAL(findByIdQuery.First())
                         ));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieves a TaskItemDAL with an Id corresponding to the id parameter from the repository
        /// </summary>
        /// <param name="id">
        /// Unique Id of the TaskItem to retrieve
        /// </param>
        /// <returns>
        /// </returns>
        public Maybe <TaskItemDAL> GetById(Guid id)
        {
            var findTaskQuery = GetQueryForId(id);

            if (findTaskQuery.Count() != 1)
            {
                return(Maybe <TaskItemDAL> .CreateEmpty());
            }
            else
            {
                //get the custom notification frequency that may be associated with
                //the TaskItem
                Maybe <CustomNotificationFrequencyDAL> maybeNotificationFrequency =
                    notificationFrequencyRepository.GetById(id);

                return(Maybe <TaskItemDAL> .Create(
                           DataToTaskItemDAL(findTaskQuery.First(), maybeNotificationFrequency)
                           ));
            }
        }