protected override void Seed(ServiceCentreDBContext db)
        {
            StatusOfApplication status1 = new StatusOfApplication()
            {
                Name = "New"
            };
            StatusOfApplication status2 = new StatusOfApplication()
            {
                Name = "In Progress"
            };
            StatusOfApplication status3 = new StatusOfApplication()
            {
                Name = "Completed"
            };
            StatusOfApplication status4 = new StatusOfApplication()
            {
                Name = "Closed"
            };

            db.Statuses.AddRange(new List <StatusOfApplication>()
            {
                status1, status2, status3, status4
            });
            ApplicationRole role1 = new ApplicationRole()
            {
                Name = "admin"
            };
            ApplicationRole role2 = new ApplicationRole()
            {
                Name = "user"
            };
            ApplicationRole role3 = new ApplicationRole()
            {
                Name = "manager"
            };

            db.Roles.Add(role1);
            db.Roles.Add(role2);
            db.Roles.Add(role3);

            /*User user1 = new User() { Login = "******", Name = "user1Name" };
             * User user2 = new User() { Login = "******", Name = "user2Name" };
             * User user3 = new User() { Login = "******", Name = "user3Name" };
             * User user4 = new User() { Login = "******", Name = "user4Name" };
             * db.Users.AddRange(new List<User>() { user1, user1, user3 });
             *
             * Application application1 = new Application() { ApplicationName = "app1", Status = status1, UserOwner = user3 };
             * Application application2 = new Application() { ApplicationName = "app2", Status = status1, UserOwner = user3 };
             * Application application3 = new Application() { ApplicationName = "app3", Status = status1, UserOwner = user4 };
             * db.Applications.AddRange(new List<Application>() { application1, application2, application3});
             */
            db.SaveChanges();
            base.Seed(db);
        }
Пример #2
0
        public void Create(StatusDTO item)
        {
            if (item == null)
            {
                throw new ValidationException("Invalid input status", "");
            }
            var newStatus = new StatusOfApplication()
            {
                Name = item.Name
            };

            try
            {
                _dataBase.Statuses.Create(newStatus);
                _dataBase.Save();
            }
            catch (Exception)
            {
                throw new ValidationException("Error while creating new status", "");
            }
        }