Exemplo n.º 1
0
        public static async Task Seed(AviTrackrDbContext context)
        {
            var exists = await context.MyTaskStatuses.AnyAsync();

            if (!exists)
            {
                context.MyTaskStatuses.Add(new MyTaskStatus
                {
                    StatusName        = "Not Started",
                    StatusDescription = "Have not started the Task"
                });
                context.MyTaskStatuses.Add(new MyTaskStatus
                {
                    StatusName        = "Pending",
                    StatusDescription = "Wait on something else"
                });
                context.MyTaskStatuses.Add(new MyTaskStatus
                {
                    StatusName        = "In Progress",
                    StatusDescription = "The task has started but not yet finished"
                });
                context.MyTaskStatuses.Add(new MyTaskStatus
                {
                    StatusName        = "Done",
                    StatusDescription = "The task is completed."
                });
                context.MyTaskStatuses.Add(new MyTaskStatus
                {
                    StatusName        = "Removed",
                    StatusDescription = "The task is no longer necessary."
                });
                await context.SaveChangesAsync();
            }
        }
Exemplo n.º 2
0
            public async Task <Command> Handle(Command request, CancellationToken cancellationToken)
            {
                var user = await _context.UserProfiles.FirstOrDefaultAsync(x => x.Email == request.UserName, cancellationToken);

                var status = await _context.MyTaskStatuses.FirstOrDefaultAsync(s => s.Id == request.Status.Id, cancellationToken);

                if (user == null)
                {
                    return(null);
                }

                var myTask = _mapperWrapper.Map <Command, MyTask>(request);

                myTask.UserProfile   = user;
                myTask.UserProfileId = user.Id;
                myTask.Status        = status;

                _context.Tasks.Add(myTask);

                await _context.SaveChangesAsync(cancellationToken);

                var result = _mapperWrapper.Map <MyTask, AddMyTask.Command>(myTask);

                myTask.UserProfileId = 0;

                return(result);
            }
Exemplo n.º 3
0
        public static async Task Seed(AviTrackrDbContext context)
        {
            var exists = await context.NotificationTypes.AnyAsync();

            if (exists)
            {
                return;
            }
            context.NotificationTypes.Add(new NotificationType {
                NotificationTypeName = "Email"
            });
            context.NotificationTypes.Add(new NotificationType {
                NotificationTypeName = "SMS"
            });
            context.NotificationTypes.Add(new NotificationType {
                NotificationTypeName = "Alexa"
            });
            await context.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public static async Task Seed(AviTrackrDbContext context)
        {
            bool exists = await context.UserProfiles.AnyAsync();

            if (exists == false)
            {
                context.UserProfiles.Add(new UserProfile()
                {
                    Email           = "*****@*****.**", FirstName = "Steven", LastName = "Moseley",
                    UserPermissions = new List <UserPermission>()
                    {
                        new UserPermission()
                        {
                            Value = "admin"
                        }
                    }
                });
                await context.SaveChangesAsync();
            }
        }