Ejemplo n.º 1
0
 public static void Delete(CinemaAmenity item)
 {
     try
     {
         var items = GetAll();
         var itemToDelete = items.Where(p => p.Id == item.Id).FirstOrDefault();
         items.Remove(itemToDelete);
         Add(items);
     }
     catch { }
 }
Ejemplo n.º 2
0
        public static void Add(CinemaAmenity item)
        {
            try
            {
                var items = GetAll();

                if (items.Any(p => p.Id == item.Id || (p.CinemaId == item.CinemaId && p.AmenityId == item.AmenityId)))
                    return;

                items.Add(item);
                Add(items);
            }
            catch { }
        }
Ejemplo n.º 3
0
        public static void Update(CinemaAmenity item)
        {
            try
            {
                var items = GetAll();

                var oldItem = items.Where(p => p.Id == item.Id).FirstOrDefault();

                items.Remove(oldItem);
                items.Add(item);

                Add(items);
            }
            catch { }
        }
Ejemplo n.º 4
0
        public ActionResult ManageAmenities(IEnumerable<CheckboxViewModel> checkboxes, Guid cinemaId)
        {
            var selectedItems = checkboxes.Where(x => x.IsChecked);
            var format = string.Join(",", selectedItems.Select(x => x.Name));

            CinemaAmenities.DeleteByCinemaId(cinemaId);

            foreach (var item in selectedItems)
            {
                var cinemaAmenity = new CinemaAmenity
                {
                    Id = Guid.NewGuid(),
                    CinemaId = cinemaId,
                    AmenityId = item.Id,
                };

                CinemaAmenities.Add(cinemaAmenity);
            }

            return RedirectToAction("ManageAmenities", new { @id = cinemaId });
        }