private void DeleteEntry(object sender, RoutedEventArgs e)
        {
            if (ORM.SelectedItem is Part)
            {
                Part selected = (Part)ORM.SelectedItem;
                context.Parts.Remove(selected);
                //Manufacturer man = selected.Manufacturer;
                //man.Parts.Remove(selected);
            }
            else if (ORM.SelectedItem is Manufacturer)
            {
                // TODO: Make sure the user wants to delete all entries for this manufacturer
                Manufacturer selected = (Manufacturer)ORM.SelectedItem;
                if (selected.Parts.Count > 0)
                {
                    MessageBoxResult mr = MessageBox.Show("Are you sure you want to delete this manufacturer and ALL of this manufacturer's parts?",
                                                          "Delete manufacturer", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No);

                    if (mr == MessageBoxResult.Yes)
                    {
                        context.Manufacturers.Remove(selected);
                    }
                }
                else
                {
                    context.Manufacturers.Remove(selected);
                }
            }

            context.SaveChanges();
        }
Пример #2
0
 public int UpdateCardCompany(CardCompany cardCompany)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(cardCompany).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Пример #3
0
 public int AddCurrency(Currency currency)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Currencies.Add(currency);
         return(ctx.SaveChanges());
     }
 }
Пример #4
0
 public int AddCard(Card card)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Cards.Add(card);
         return(ctx.SaveChanges());
     }
 }
Пример #5
0
 public int UpdateCurrency(Currency currency)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(currency).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Пример #6
0
 public int UpdateMovement(Movement movement)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(movement).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Пример #7
0
 public int AddMovement(Movement movement)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Movements.Add(movement);
         return(ctx.SaveChanges());
     }
 }
Пример #8
0
 public int AddAccount(Account account)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Accounts.Add(account);
         return(ctx.SaveChanges());
     }
 }
Пример #9
0
 public int UpdateAccount(Account account)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(account).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Пример #10
0
 public int AddCardCompany(CardCompany cardCompany)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.CardCompanies.Add(cardCompany);
         return(ctx.SaveChanges());
     }
 }
Пример #11
0
 public static List <User> AddExampleUsersToDatabase(DbContextOptions <OrganizerContext> dbContextOptions, MiniAutoFixture miniAutoFixture)
 {
     using (OrganizerContext organizerContext = new OrganizerContext(dbContextOptions))
     {
         List <User> userList = Enumerable.Range(1, 10).Select(a => CreateUser(0, miniAutoFixture)).ToList();
         userList.ForEach(user => organizerContext.Add(user));
         organizerContext.SaveChanges();
         return(userList);
     }
 }
Пример #12
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Day currentDay = Week.WeekDays[0];

            controller.AddTask(currentDay, title.Text, key_words.Text, description.Text);
            context.SaveChanges();

            title.Clear();
            key_words.Clear();
            description.Clear();
        }
Пример #13
0
 public int RemoveMovement(long entryId)
 {
     using (var ctx = new OrganizerContext())
     {
         var entry = ctx.Movements.Find(entryId);
         if (entry == null)
         {
             return(0);
         }
         ctx.Movements.Remove(entry);
         return(ctx.SaveChanges());
     }
 }
Пример #14
0
 public int RemoveCardCompany(long cardCompanyId)
 {
     using (var ctx = new OrganizerContext())
     {
         var cardCompany = ctx.CardCompanies.Find(cardCompanyId);
         if (cardCompany == null)
         {
             return(0);
         }
         ctx.CardCompanies.Remove(cardCompany);
         return(ctx.SaveChanges());
     }
 }
Пример #15
0
        public UserView InsertUser(UserModify userModify)
        {
            User user = new User {
                Deleted = false
            };

            user.SaveUserModify(userModify);
            _organizerContext.User.Add(user);
            _organizerContext.SaveChanges();
            return(_organizerContext.User.Where(a => a.Id == user.Id).Select(a => a.MapUserToView()).Single());
        }
Пример #16
0
 public int RemoveAccount(long accountId)
 {
     using (var ctx = new OrganizerContext())
     {
         var account = ctx.Accounts.Find(accountId);
         if (account == null)
         {
             return(0);
         }
         ctx.Accounts.Remove(account);
         return(ctx.SaveChanges());
     }
 }
Пример #17
0
 public int RemoveCurrency(long currencyId)
 {
     using (var ctx = new OrganizerContext())
     {
         var currency = ctx.Currencies.Find(currencyId);
         if (currency == null)
         {
             return(0);
         }
         ctx.Currencies.Remove(currency);
         return(ctx.SaveChanges());
     }
 }
Пример #18
0
        static void Main(string[] args)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <OrganizerContext, Configuration>());

            using (var context = new OrganizerContext())
            {
                var user = context.Users.FirstOrDefault(u => u.Username == "bayIvan5");

                if (user == null)
                {
                    user             = new User();
                    user.AuthCode    = "0123456789012345678901234567890123456789";
                    user.DisplayName = "Ivan Ivanov2";
                    user.Username    = "******";

                    context.Users.Add(user);
                    context.SaveChanges();
                }
                Item rootUserItem = new Item();
                rootUserItem.ItemType = ItemType.Type;
                rootUserItem.Title    = "Root";
                rootUserItem.User     = user;

                context.Items.Add(rootUserItem);



                Location loc = new Location();
                loc.Latitude  = 40;
                loc.Longitude = 20;
                loc.ItemId    = 4;
                context.Locations.Add(loc);

                context.SaveChanges();
            }
        }
Пример #19
0
        //opens the current week , that's going
        public List <Day> OpenWeek()
        {
            Day today = CheckCurrentDay();

            Week.WeekDays = new List <Day>();

            if (Week.WeekDays.Count > 0)
            {
                Week.WeekDays.Clear();
            }

            Week.WeekDays.AddRange(context.Days.Where(x => x.weekID == today.weekID));
            Week.WeekDays.OrderBy(x => x.date).ToList();

            context.SaveChanges();
            return(Week.WeekDays);
        }
Пример #20
0
        public async Task <IActionResult> PostList(int id, [FromBody] ApplicationUser applicationuser)
        {
            var userId = _userManager.GetUserId(User);

            var list = _context.Lists.Include(q => q.Todos)
                       .Where(q => _context.Permissions.Any(r => r.List.Id == id && r.User.Id == userId))
                       .FirstOrDefault(p => p.Id == id);

            var user = await _userManager.FindByEmailAsync(applicationuser.Email);

            var permission = new Permission();

            permission.List = list;
            permission.User = user;

            _context.Permissions.Add(permission);

            _context.SaveChanges();

            return(Ok(permission));
        }
Пример #21
0
        public static List <Task> AddExampleTasksToDatabase(DbContextOptions <OrganizerContext> dbContextOptions, MiniAutoFixture miniAutoFixture, out List <User> userList)
        {
            using (OrganizerContext organizerContext = new OrganizerContext(dbContextOptions))
            {
                userList = new List <User>();
                User user1 = DbSetTools.CreateUser(0, miniAutoFixture);
                organizerContext.Add(user1);
                userList.Add(user1);

                User user2 = DbSetTools.CreateUser(0, miniAutoFixture);
                organizerContext.Add(user2);
                userList.Add(user2);

                User user3 = DbSetTools.CreateUser(0, miniAutoFixture);
                organizerContext.Add(user3);
                userList.Add(user3);

                List <Task> taskList = Enumerable
                                       .Range(1, 10)
                                       .Select(a => CreateTask(0, user1, miniAutoFixture))
                                       .ToList()
                                       .Concat(
                    Enumerable.Range(11, 10)
                    .Select(a => CreateTask(0, user2, miniAutoFixture))
                    .ToList()
                    )
                                       .Concat(
                    Enumerable.Range(21, 10)
                    .Select(a => CreateTask(0, user3, miniAutoFixture))
                    .ToList()
                    )
                                       .ToList();



                taskList.ForEach(task => organizerContext.Add(task));
                organizerContext.SaveChanges();
                return(taskList);
            }
        }
 // Opslaan
 public bool Opslaan()
 {
     return(_context.SaveChanges() >= 0);
 }
Пример #23
0
 private void DiaryDone(Diaryes diary)
 {
     db.Entry(diary).State = EntityState.Modified;
     diary.DoneStatus      = 1;
     db.SaveChanges();
 }
 // Fabrieksinstellingen terugzetten
 public void FabrieksInstellingenVerwijderAlles()
 {
     _context.Logins.RemoveRange(_context.Logins.ToList());
     _context.SaveChanges();
 }