Exemple #1
0
        public void Delete(HallDomainModel entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            Hall hall = Mapper.Map <HallDomainModel, Hall>(entity);

            Uow.GetRepository <Hall>().Delete(hall);
            Uow.Save();
        }
Exemple #2
0
        public HallDomainModel ReadById(object id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            Hall            hall       = Uow.GetRepository <Hall>().ReadById(id);
            HallDomainModel hallDomain = Mapper.Map <Hall, HallDomainModel>(hall);

            return(hallDomain);
        }
        public ActionResult Edit([Bind(Include = "Id,Name,RowAmount,ColumnAmoun,CinemaId")] HallViewModel hallViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(hallViewModel));
            }
            HallDomainModel hallDomainModel = Mapper.Map <HallViewModel, HallDomainModel>(hallViewModel);

            _hallService.Update(hallDomainModel);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([FromJson] HallViewModel hallViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(hallViewModel));
            }
            HallDomainModel hallDomainModel = Mapper.Map <HallViewModel, HallDomainModel>(hallViewModel);

            _hallService.Add(hallDomainModel);
            return(RedirectToAction("Details", "Cinema", new { id = hallDomainModel.CinemaId }));
        }
        public ActionResult DeleteConfirmed(long id)
        {
            HallDomainModel hallDomainModel = _hallService.ReadById(id);

            if (hallDomainModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            _hallService.Delete(hallDomainModel);
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HallDomainModel hallDomainModel = _hallService.ReadById(id);

            if (hallDomainModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            HallViewModel hallViewModel = Mapper.Map <HallDomainModel, HallViewModel>(hallDomainModel);

            return(View(hallViewModel));
        }