public IMZCommandResult Execute(TCreateUpdateCommand command) { var sucesso = true; MZServerError error = null; try { _unitOfWork.StartTrans(); var entity = GetEntityToSave(command); _reposity.Save(entity, true); _unitOfWork.Commit(); } catch (Exception ex) { _unitOfWork.Rollback(); sucesso = false; error = new MZServerError(ex); } return(new MZCommandResult(sucesso, error)); }
public IMZCommandResult Execute(TDeleteCommand command) { var sucesso = true; MZServerError error = null; try { _unitOfWork.StartTrans(); var entity = _reposity.GetById(command.ID); _reposity.Delete(entity); _unitOfWork.Commit(); } catch (Exception ex) { _unitOfWork.Rollback(); sucesso = false; error = new MZServerError(ex); } return(new MZCommandResult(sucesso, error)); }
public MZCommandResult(bool success, MZServerError error) { this.Success = success; this.Error = error; }
protected void SetViewDataError(MZServerError errorServer, string erroKey) { ViewData[erroKey] = errorServer; }