public async Task <IActionResult> Create([Bind("Id,Name,Color,Size,TotalQuantityInInventory,IsActive")] SwagItem swagItem)
        {
            var TerritorySwagItems = new List <TerritorySwagItem>();
            var territories        = _context.Territory.ToList();

            if (ModelState.IsValid)
            {
                _context.Add(swagItem);
                await _context.SaveChangesAsync();

                foreach (var territory in territories)
                {
                    TerritorySwagItems.Add(new TerritorySwagItem
                    {
                        SwagItemId  = swagItem.Id,
                        TerritoryId = territory.Id,
                        QuantityInTerritoryInventory = 0
                    });
                }
                _context.AddRange(TerritorySwagItems);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(swagItem));
        }
예제 #2
0
 public void MarkAsSwagged(SwagItem swag)
 {
     _swagRepository.MarkAsSwagged(swag);
 }
예제 #3
0
 public void AddSwag(SwagItem swag)
 {
     _swagRepository.AddSwag(swag);
 }
 public void AttendeeReceivedSwag(Attendee attendee, SwagItem swagItem)
 {
     attendee.ReceivedSwag.Add(swagItem.Name);
 }
예제 #5
0
 public void MarkAsSwagged(SwagItem swagItem)
 {
     swagItem.HasBeenSwagged = true;
 }
예제 #6
0
 public void RemoveSwag(SwagItem swag)
 {
     _swag.Remove(swag);
 }
예제 #7
0
 public void AddSwag(SwagItem swag)
 {
     _swag.Add(swag);
 }
 public void AttendeeReceivedSwag(Attendee attendee, SwagItem swag)
 {
     _attendeeRepository.AttendeeReceivedSwag(attendee, swag);
 }