Esempio n. 1
0
        public ApiResponseModel <Seance> Add([FromBody] AddRequestModel requestModel)
        {
            var responseModel = new ApiResponseModel <Seance>();

            try
            {
                var record = new Seance();
                record.Name      = requestModel.Name;
                record.Date      = requestModel.Date;
                record.Time      = requestModel.Time;
                record.IsDeleted = false;
                var dbResult = _seanceService.Add(record);
                if (dbResult > 0)
                {
                    responseModel.Data                = record; // oluşturulan entity bilgisinde id kolonu atanmış olur ve entity geri gönderiliyor
                    responseModel.ResultStatusCode    = ResultStatusCodeStatic.Success;
                    responseModel.ResultStatusMessage = "Success";
                }
                else
                {
                    responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                    responseModel.ResultStatusMessage = "Could Not Be Saved";
                }
            }
            catch (Exception ex)
            {
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                responseModel.ResultStatusMessage = ex.Message;
            }
            return(responseModel);
        }
Esempio n. 2
0
 private void btnAddSeance_Click(object sender, EventArgs e)
 {
     _seanceService.Add(new Seance
     {
         Time = txtSeance.Text
     });
     ScreenUpdate();
 }
Esempio n. 3
0
        public ActionResult Create(CreateSeanceViewModel createSeanceViewModel)
        {
            if (createSeanceViewModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.HallsCinemas = GetHallsCinemas();
                return(PartialView("_CreatePartial", createSeanceViewModel));
            }

            if (createSeanceViewModel.IsMultipleDateSelect)
            {
                var startDate = DateTime.ParseExact(createSeanceViewModel.Date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                var endDate   = DateTime.ParseExact(createSeanceViewModel.EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                for (var date = startDate; date <= endDate; date = date.AddDays(1.0))
                {
                    SeanceViewModel   baseSeanceViewModel  = createSeanceViewModel;
                    SeanceDomainModel newSeanceDomainModel = Mapper.Map <SeanceViewModel, SeanceDomainModel>(baseSeanceViewModel);
                    newSeanceDomainModel.Date = date;
                    _seanceService.Add(newSeanceDomainModel);
                }
            }
            else
            {
                SeanceViewModel   seanceViewModel   = createSeanceViewModel;
                SeanceDomainModel seanceDomainModel = Mapper.Map <SeanceViewModel, SeanceDomainModel>(seanceViewModel);
                _seanceService.Add(seanceDomainModel);
            }

            var url = Url.Action("List", "Seance", routeValues: new { filmId = createSeanceViewModel.FilmId });

            return(Json(new { success = true, url = url, replaceTarget = "#SeanceList" }));
        }
Esempio n. 4
0
        public ActionResult Add(Models.Seance.AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                //select lists
                return(View(model));
            }
            Business.Models.Seance.Seance seance = new Business.Models.Seance.Seance();
            seance.Name = model.Name;
            seance.Date = model.Date;
            seance.Time = model.Time;
            var apiResponseModel = _seanceService.Add(SessionHelper.CurrentUser.UserToken, seance);

            if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success)
            {
                return(RedirectToAction(nameof(SeanceController.List)));
            }
            else
            {
                ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage != null ? apiResponseModel.ResultStatusMessage : "Not Saved";
                return(View(model));
            }
        }
Esempio n. 5
0
 public void Post([FromBody] Seance seance)
 {
     seanceService.Add(seance);
 }