Ejemplo n.º 1
0
        public bool DeleteCinema(CinemaDto cinema)
        {
            var isExist = GetAllCinema().Contains(cinema);

            if (!isExist)
            {
                return(false);
            }
            else
            {
                Delete(Mapper.Map <Cinema>(cinema));
                Work.SaveChanges();
                return(true);
            }
        }
Ejemplo n.º 2
0
        public async Task <CinemaDto> UpdateAsync(CinemaDto cinema)
        {
            var source = await cinemaRepository.GetAsync(cinema.CinemaId);

            if (source == null)
            {
                throw new NullReferenceException();
            }
            var target = mapper.Map <Cinema>(cinema);
            var result = await cinemaRepository.UpdateAsync(target);

            var resultDto = mapper.Map <CinemaDto>(result);

            return(resultDto);
        }
Ejemplo n.º 3
0
 public IValitResult Validate(CinemaDto dto, IValitStrategy strategy = null)
 => ValitRules <CinemaDto>
 .Create()
 .WithStrategy(s => s.Complete)
 .Ensure(c => c.Id, _ => _
         .IsNotEmpty())
 .Ensure(c => c.Name, _ => _
         .Required())
 .Ensure(c => c.Address, _ => _
         .Required())
 .Ensure(c => c.Address, new AddressDtoValidator())
 .Ensure(c => c.Halls, _ => _
         .MinItems(1))
 .EnsureFor(c => c.Halls, new HallDtoValidator())
 .For(dto)
 .Validate();
Ejemplo n.º 4
0
        public bool CreateCinema(CinemaDto cinema)
        {
            var entity = new Cinema
            {
                CinemaName        = cinema.CinemaName,
                Telephone         = cinema.Telephone,
                Address_Longitude = cinema.Address_Longitude,
                Address_Latitude  = cinema.Address_Latitude,
                WebSite           = cinema.WebSite,
                Raiting           = cinema.Raiting,
                Image             = cinema.Image,
            };

            Insert(entity);
            Work.SaveChanges();
            return(true);
        }
Ejemplo n.º 5
0
        public CinemaViewModel(ICinemaRequest cinemaData)
        {
            #region HttpDataproxy Initiliaze
            CinemaDataHttpProxy = cinemaData;
            #endregion

            #region ObservableCollections Initialize
            CinemaList = new ObservableCollection <CinemaDto>();
            Refresh();
            SelectedCinema = new CinemaDto();
            #endregion

            #region Command Initialisation
            RefreshCinemaLits = new RelayCommand(Refresh);
            AddCinema         = new RelayCommand(() => new CreateCinema().Show());

            #endregion
        }
Ejemplo n.º 6
0
        private void ImportCinema(CinemaDto cinemaDto)
        {
            string townName = cinemaDto.TownName;

            InputDataValidator.ValidateStringMaxLength(townName, Constants.MaxTownNameLength);

            string cinemaName = cinemaDto.Name;

            InputDataValidator.ValidateStringMaxLength(cinemaName, Constants.MaxCinemaNameLength);

            townService.AddTownIfNotExisting(townName);
            int townId = townService.GetTownId(townName);

            cinemaValidator.ValidateCinemaDoesNotExist(cinemaName, townId);

            cinemaService.AddCinema(cinemaName, townId);

            Console.WriteLine(string.Format(Constants.ImportSuccessMessages.CinemaAddedSuccess, cinemaName));
        }
Ejemplo n.º 7
0
 public static CinemaDocument AsDocument(this CinemaDto dto)
 => new CinemaDocument
Ejemplo n.º 8
0
 public Task UpdateAsync(CinemaDto dto)
 => _repository.UpdateAsync(dto.AsDocument());