Esempio n. 1
0
        public static ManualDelete GetViewModel(BaseController baseController, int id, out DeleteResult deleteResult)
        {
            deleteResult = DeleteResult.Ok;

            Manual manual = ManualCache.GetDetail(baseController.Db, id);
            if (manual == null)
                return null;

            var manualDelete = new ManualDelete(manual);
            manualDelete.Process(baseController);

            if (baseController.ModelState.IsValid)
            {
                deleteResult = ManualCache.Delete(baseController.Db, manual);

                switch (deleteResult)
                {
                    case DeleteResult.Ok:
                    case DeleteResult.AuthorizationFailed:
                        return manualDelete;

                    case DeleteResult.DbFailed:
                        baseController.ModelState.AddModelError(BaseCache.TitleField, ValidationResource.Global_DeleteRecord_ErrorMessage);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            return manualDelete;
        }
Esempio n. 2
0
        public static ManualDelete GetViewModel(BaseController baseController, int id)
        {
            Manual manual = ManualCache.GetDetail(baseController.Db, id);
            if (manual == null)
                return null;

            var manualDelete = new ManualDelete(manual);
            return manualDelete;
        }