Пример #1
0
        public ApiResponseModel <MoviesType> Delete([FromBody] DeleteRequestModel requestModel)
        {
            var responseModel = new ApiResponseModel <MoviesType>();

            try
            {
                var record   = _moviesTypeService.GetById(requestModel.Id);
                var dbResult = _moviesTypeService.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);
        }
Пример #2
0
        public ActionResult Delete(int id)
        {
            Models.MoviesType.AddViewModel model = new AddViewModel();
            //select lists
            var apiResponseModel = _moviesTypeService.GetById(SessionHelper.CurrentUser.UserToken, id);

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

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

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

            return(RedirectToAction(nameof(MoviesTypeController.List)));
        }