示例#1
0
        public ActionResult Delete(int id, string returnUrl)
        {
            try
            {
                var item = _placesService.GetCityById(id);
                if (item == null)
                {
                    AddMessageToTempData(CommonResources.NoDataFound, BusinessSolutions.MVCCommon.MessageType.Error);
                }
                else
                {
                    var result = _placesService.DeleteCity(id);
                    if (result)
                    {
                        AddMessageToTempData(CommonResources.DeleteSuccessfully, BusinessSolutions.MVCCommon.MessageType.Success);
                    }
                    else
                    {
                        AddMessageToTempData(CommonResources.DeleteError, BusinessSolutions.MVCCommon.MessageType.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                this.Logger.Error(ex);
                AddMessageToView(CommonResources.SavedSuccessfullyMessage, BusinessSolutions.MVCCommon.MessageType.Error);
            }

            if (string.IsNullOrEmpty(returnUrl) && !Url.IsLocalUrl(returnUrl))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToLocal(returnUrl));
            }
        }