public static GeoTaskUpdateCommand ToGeoTaskUpdateCommand
            (this ApiGeoTaskUpdateCommand from, string id,
            ClaimsPrincipal currentPrincipal)
        {
            if (from is null)
            {
                return(null);
            }

            var to = new GeoTaskUpdateCommand
            {
                Description        = from.Description,
                Id                 = id,
                PlanFinishAt       = from.PlanFinishAt,
                PlanStartAt        = from.PlanStartAt,
                ProjectId          = from.ProjectId,
                ResponsibleActorId = from.ResponsibleActorId,
                Title              = from.Title,
                CurrentPrincipal   = currentPrincipal,
                IsArchived         = from.IsArchived,
                Status             = EnumerationClass
                                     .GetAll <GeoTaskStatus>()
                                     .Where(x => x.Id == from.Status)
                                     .FirstOrDefault(),
                MessageTitle       = from.MessageTitle,
                MessageDescription = from.MessageDescriprion
            };

            to.AssistentActorsIds.AddRange(from.AssistentActorsIds);
            to.GeosIds.AddRange(from.GeosIds);
            to.ObserverActorsIds.AddRange(from.ObserverActorsIds);
            return(to);
        }
Exemplo n.º 2
0
        public static GeoTaskUpdateCommand ToGeoTaskUpdateCommand
            (this ApiGeoTask from, string id, ClaimsPrincipal currentPrincipal,
            string messageTitle, string messageDescription)
        {
            if (from is null)
            {
                return(null);
            }

            var to = new GeoTaskUpdateCommand
            {
                Description        = from.Description,
                Id                 = id,
                PlanFinishAt       = from.PlanFinishAt,
                PlanStartAt        = from.PlanStartAt,
                ProjectId          = from.ProjectId,
                ResponsibleActorId = from.ResponsibleActor?.Id,
                Title              = from.Title,
                CurrentPrincipal   = currentPrincipal,
                IsArchived         = from.IsArchived,
                Status             = from.Status,
                MessageDescription = messageDescription,
                MessageTitle       = messageTitle
            };

            to.AssistentActorsIds
            .AddRange(from.AssistentActors.Select(x => x.Id));
            to.GeosIds.AddRange(from.GeosIds);
            to.ObserverActorsIds
            .AddRange(from.ObserverActors.Select(x => x.Id));
            return(to);
        }
        public static Dictionary <string, object> ToDictionary
            (this GeoTaskUpdateCommand from)
        {
            if (from is null)
            {
                return(null);
            }

            return(new Dictionary <string, object>
            {
                { nameof(from.Description), from.Description },
                { nameof(from.IsArchived), from.IsArchived },
                { nameof(from.PlanFinishAt), from.PlanFinishAt },
                { nameof(from.PlanStartAt), from.PlanStartAt },
                { nameof(from.ProjectId), from.ProjectId },
                { nameof(from.Title), from.Title },
                { nameof(from.AssistentActorsIds),
                  String.Join(',', from.AssistentActorsIds) },
                {
                    nameof(from.CurrentPrincipal),
                    from.CurrentPrincipal
                    .ToDictionary()
                    .ToList()
                    .Select(x => $"\"{x.Key}\"={x.Value}")
                },
                { nameof(from.GeosIds), String.Join(',', from.GeosIds) },
                { nameof(from.ObserverActorsIds),
                  String.Join(',', from.ObserverActorsIds) },
                { nameof(from.ResponsibleActorId), from.ResponsibleActorId },
                { nameof(from.Id), from.Id },
                { nameof(from.MessageDescription), from.MessageDescription },
                { nameof(from.MessageTitle), from.MessageTitle },
                { nameof(from.Status), from.Status },
            });
        }