public ActionResult Edit(Resource r)
        {
            var c = new UpdateResourceCommand {Resource = r};
            var res = c.Execute(_serviceResource);
            TempData["CommandResult"] = res;

            return RedirectToAction("Edit", r.Id);
        }
        public ActionResult Undo(Guid? id)
        {
            var undo = _serviceResource.GetSaveUndoCommand(id.Value);
            var undoSer = undo.SerializedCommand;
            var u = new UpdateResourceCommand();
            var typeRegistry = new XmlStringSerializableTypeRegistry();
            typeRegistry.RegisterType(u.GetType());
            var ser = new XmlStringDeserializer(typeRegistry);
            var undoO = ser.Deserialize(undoSer) as UpdateResourceCommand;
            undoO.Execute(_serviceResource);

            return RedirectToAction("Edit", new { id = undoO.Resource.Id});
        }
        public CommandResult Execute(IResourceService iResourceService)
        {
            var result = new CommandResult();
            if(!IsUndo)
            {

                var undo = new UpdateResourceCommand
                                                 {Resource = iResourceService.GetResource(_resource.Id), IsUndo = true};

                var ser = new XmlStringSerializer();

                var serialized = ser.Serialize(undo);

                var suc = new SavedUndoCommand
                {
                    Id = Guid.NewGuid(),
                    CreatedDate = DateTime.Now,
                    SerializedCommand = serialized
                };

                result.UndoCommandId = iResourceService.SaveUndoCommand(suc);

            }

            iResourceService.UpdateResourceCategories(_resource);
            return result;
        }