public void Add(User user)
        {
            // user.Weeks = new Week[52];
            for (int i = 1; i < 53; i++)
            {
                _context.Weeks.Add(new Week {
                    Id            = this.createUniqueId() + i,
                    WeekNumber    = i,
                    Year          = 1900,
                    HoursWorked   = 0,
                    UserId        = user.Id,
                    Week_complete = false
                });
            }

            /* foreach (Week week in user.Weeks)
             * {
             *  Logger.Info(this, $"user week: {week}");
             *      week.Id=this.createUniqueId();
             *      week.WeekNumber=1;
             *      week.Year=1900;
             *      week.HoursWorked=0;
             *      week.UserId = "dummy";
             *      week.Week_complete=false;
             * }; */
            _context.Users.Add(user);
            _context.SaveChanges();
        }
        public void Add(Suggestion suggestion)
        {
            int        id_to_add        = suggestion.Id;
            Booking    check_booking    = _context.Bookings.Where(b => b.Id == id_to_add).FirstOrDefault();
            Suggestion check_suggestion = _context.Suggestions.Where(s => s.Id == id_to_add).FirstOrDefault();

            if ((check_booking == null) && (check_suggestion == null))
            {
                _context.Suggestions.Add(suggestion);
                _context.SaveChanges();
            }
            else
            {
                throw new System.InvalidOperationException("Id of suggestion is already in use");
            }
        }
Ejemplo n.º 3
0
 public void Add(Week week)
 {
     _context.Weeks.Add(week);
     _context.SaveChanges();
 }