public ActionResult Delete(int id)
        {
            Models.Seance.AddViewModel model = new AddViewModel();
            //select lists

            var apiResponseModel = _seanceService.GetById(SessionHelper.CurrentUser.UserToken, id);

            if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage;
                return(RedirectToAction(nameof(SeanceController.List)));
            }
            var seance = apiResponseModel.Data;

            if (seance == null)
            {
                ViewBag.ErrorMessage = "Not Found Record";
                return(RedirectToAction(nameof(SeanceController.List)));
            }
            var apiDeleteResponseModel = _seanceService.Delete(SessionHelper.CurrentUser.UserToken, id);

            if (apiDeleteResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage = apiDeleteResponseModel.ResultStatusMessage;
                return(RedirectToAction(nameof(SeanceController.List)));
            }

            return(RedirectToAction(nameof(SeanceController.List)));
        }
        public ApiResponseModel <Seance> Delete([FromBody] DeleteRequestModel requestModel)
        {
            var responseModel = new ApiResponseModel <Seance>();

            try
            {
                var record   = _seanceService.GetById(requestModel.Id);
                var dbResult = _seanceService.Delete(record);

                if (dbResult > 0)
                {
                    responseModel.Data                = record; // 'isDeleted= true' yapılan -> entity bilgisi geri gönderiliyor
                    responseModel.ResultStatusCode    = ResultStatusCodeStatic.Success;
                    responseModel.ResultStatusMessage = "Success";
                }
                else
                {
                    responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                    responseModel.ResultStatusMessage = "Could Not Be Deleted";
                }
            }
            catch (Exception ex)
            {
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                responseModel.ResultStatusMessage = ex.Message;
            }
            return(responseModel);
        }
Beispiel #3
0
        private void btnDeleteSeance_Click(object sender, EventArgs e)
        {
            int id = (int)dgvSeance.CurrentRow.Cells[0].Value;

            _seanceService.Delete(id);
            ScreenUpdate();
        }
        public ActionResult Delete(long seanceId)
        {
            SeanceDomainModel seanceDomainModel = _seanceService.ReadById(seanceId);

            if (seanceDomainModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SeanceViewModel seanceViewModel = Mapper.Map <SeanceDomainModel, SeanceViewModel>(seanceDomainModel);

            if (!ModelState.IsValid)
            {
                return(PartialView("_DeletePartial", seanceViewModel));
            }

            _seanceService.Delete(seanceDomainModel);

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

            return(Json(new { success = true, url = url, replaceTarget = "#SeanceList" }));
        }