示例#1
0
        public ActionResult Edit(VenueEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var input  = MapperManager.Map <VenueDto>(model);
                var result = _venueManagementService.EditVenue(input);

                if (result.Id > 0)
                {
                    return(RedirectToAction("Index", "Venue"));
                }
            }

            return(View(model));
        }
示例#2
0
        protected override async Task SaveChanges()
        {
            // added item
            var venueModelForAdd = _dataSource.Where(x => x.Status == ModelInfo.NewItem).ToArray();

            foreach (var item in venueModelForAdd)
            {
                var venueDto = new VenueDto
                {
                    Description = item.Description,
                    Address     = item.Address,
                    Phone       = item.Phone,
                };

                _venueService.CreateVenue(venueDto);
            }

            // updated item
            var venueModelForUpdate = _dataSource.Where(x => x.Status == ModelInfo.Changed).ToArray();

            foreach (var item in venueModelForUpdate)
            {
                var venueDto = new VenueDto
                {
                    Id          = item.Id,
                    Description = item.Description,
                    Address     = item.Address,
                    Phone       = item.Phone,
                };

                _venueService.EditVenue(venueDto);
            }

            // deleted items
            var venueModelsForDelete = _dataSource.Where(x => x.Status == ModelInfo.Deleted).ToArray();

            foreach (var item in venueModelsForDelete)
            {
                var layouts = _venueService.GetVenueLayouts(item.Id).Layouts;

                foreach (var layout in layouts)
                {
                    var areas = _layoutService.GetLayoutAreas(layout.Id).Areas;

                    foreach (var area in areas)
                    {
                        var seats = _areaService.GetAreaSeats(area.Id).Seats;

                        foreach (var seatModel in seats)
                        {
                            _seatService.DeleteSeat(seatModel.Id);
                        }

                        _areaService.DeleteArea(area.Id);
                    }

                    _layoutService.DeleteLayout(layout.Id);
                }
                _venueService.DeleteVenue(item.Id);
            }
        }