Example #1
0
        private static List <TaskDto> ConvertToSqlFields(List <Tasks> tasks)
        {
            List <TaskDto> taskSqls = new List <TaskDto>();

            tasks.ForEach(task =>
            {
                TaskDto taskSql = new TaskDto()
                {
                    Id           = Convert.ToInt16(task.Id),
                    Title        = task.Title,
                    CreationTime = DateTime.Now
                };
                taskSql.State  = Convert.ToInt16(DataConvert <TaskState> .ConvertEnumValue(task.State.ToString()).ToString());
                string[] descs = task.Description.Split(',');
                foreach (string desc in descs)
                {
                    taskSql.Description += DataConvert <DescType> .ConvertEnumValue(desc).ToString() + ",";
                }
                taskSql.Description = taskSql.Description.Substring(0, task.Description.Length);
                taskSqls.Add(taskSql);
            });
            return(taskSqls);
        }