public SaveResult <POEntryModel> Save(PODTO pODTO, DateTime dateStamp) { if (pODTO.Status_FK == 0) { pODTO.Status_FK = 1; } ModelValidationResult validationResult = POValidator.Validate(pODTO); bool success = false; POEntryModel model = null; if (validationResult.IsValid) { tblT_PO po = Insert(pODTO, dateStamp); Db.SaveChanges(); pODTO.PO_PK = po.PO_PK; success = true; model = POEntryDataProvider.Get(pODTO.PO_PK); } return(new SaveResult <POEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully created." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }
public SaveResult <POEntryModel> Save(PODTO pODTO, DateTime dateStamp) { ModelValidationResult validationResult = pOValidator.Validate(pODTO); bool success = false; POEntryModel model = null; if (validationResult.IsValid) { success = true; UpdatePO(pODTO, dateStamp); Db.SaveChanges(); model = pOEntryDataProvider.Get(pODTO.PO_PK); } return(new SaveResult <POEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }