public static Model.TaskInfoSearchQuery Convert(Client.TaskInfoSearchQuery clientQuery) { if (clientQuery == null) { throw new ArgumentNullException(nameof(clientQuery)); } var sortBy = clientQuery.SortBy.HasValue ? TaskSortByConverter.Convert(clientQuery.SortBy.Value) : (Model.TaskSortBy?)null; var sortType = clientQuery.Sort.HasValue ? SortTypeConverter.Convert(clientQuery.Sort.Value) :(Models.SortType?)null; var priority = clientQuery.Priority.HasValue ? TaskPriorityConverter.Convert(clientQuery.Priority.Value) :(Model.TaskPriority?)null; var modelQuery = new Model.TaskInfoSearchQuery { Done = clientQuery.Done, Limit = clientQuery.Limit, Offset = clientQuery.Offset, CreatedFrom = clientQuery.CreatedFrom, CreatedTo = clientQuery.CreatedTo, Priority = priority, ToDeadline = clientQuery.ToDeadline, Sort = sortType, SortBy = sortBy }; return(modelQuery); }
public static Models.Tasks.TaskCreationInfo Convert(string clientUserId, ClientModels.Tasks.TaskCreationInfo clientCreationInfo) { if (clientUserId == null) { throw new ArgumentNullException(nameof(clientUserId)); } if (clientCreationInfo == null) { throw new ArgumentNullException(nameof(clientCreationInfo)); } if (!Guid.TryParse(clientUserId, out var modelUserId)) { throw new ArgumentException($"The client user id \"{clientUserId}\" is invalid.", nameof(clientUserId)); } var modelPriority = TaskPriorityConverter.Convert(clientCreationInfo.Priority); var modelCreationInfo = new Models.Tasks.TaskCreationInfo( modelUserId, clientCreationInfo.Title, clientCreationInfo.Text, clientCreationInfo.DeadLine, modelPriority); return(modelCreationInfo); }
public static Model.TaskPatchInfo Convert(Guid taskId, Client.TaskPatchInfo clientPatch) { if (clientPatch == null) { throw new ArgumentNullException(nameof(clientPatch)); } var modelPriority = TaskPriorityConverter.Convert(clientPatch.Priority); var modelPatch = new Model.TaskPatchInfo( taskId, clientPatch.Title, clientPatch.Text, modelPriority, clientPatch.DeadLine, clientPatch.Done); return(modelPatch); }
public static Client.MyTask Convert(Model.MyTask modelTask) { if (modelTask == null) { throw new ArgumentNullException(nameof(modelTask)); } var clientPriority = TaskPriorityConverter.Convert(modelTask.Priority); var clientTask = new Client.MyTask { Id = modelTask.Id.ToString(), UserId = modelTask.UserId.ToString(), Title = modelTask.Title, CreatedAt = modelTask.CreatedAt, LastUpdatedAt = modelTask.LastUpdatedAt, Priority = clientPriority, Done = modelTask.Done, DeadLine = modelTask.DeadLine, Text = modelTask.Text }; return(clientTask); }
public static Client.TaskInfo Convert(Model.TaskInfo modelTaskInfo) { if (modelTaskInfo == null) { throw new ArgumentNullException(nameof(modelTaskInfo)); } var clientPriority = TaskPriorityConverter.Convert(modelTaskInfo.Priority); var clientTaskInfo = new Client.TaskInfo { Id = modelTaskInfo.Id.ToString(), UserId = modelTaskInfo.UserId.ToString(), Title = modelTaskInfo.Title, CreatedAt = modelTaskInfo.CreatedAt, LastUpdatedAt = modelTaskInfo.LastUpdatedAt, Priority = clientPriority, Done = modelTaskInfo.Done, DeadLine = modelTaskInfo.DeadLine }; return(clientTaskInfo); }