public ActionResult BudgetSync(string formName, List <Guid> ids, List <Guid> budgetIds, bool useVersions) { List <object> syncIds = null; string syncName = null; if (useVersions) { syncIds = DynamicRepository.GetByEntity("BudgetVersion", FilterCriteriaSet.And.In(budgetIds, "BudgetId").Equal(true, "IsCurrent")).Select(bv => bv.Id).ToList(); syncName = "BudgetVersionId"; } else { syncIds = budgetIds.Cast <object>().ToList(); syncName = "BudgetId"; } foreach (var id in ids) { try { var sync = new UniversalSyncMain(formName, id, syncName, syncIds); sync.Sync(); } catch (Exception ex) { return(new ContentResult() { Content = string.Format("{{\"success\":false,\"message\":\"{0}\"}}", HttpUtility.JavaScriptStringEncode(ex.Message)) }); } } return(new ContentResult() { Content = string.Format("{{\"success\":true,\"message\":\"{0}\"}}", OptimaJet.Localization.LocalizationProvider.Provider.Get("Synchronization is successful!")) }); }
public ActionResult BudgetSync(string formName, List<Guid> ids, List<Guid> budgetIds, bool useVersions) { List<object> syncIds = null; string syncName = null; if (useVersions) { syncIds = DynamicRepository.GetByEntity("BudgetVersion", FilterCriteriaSet.And.In(budgetIds, "BudgetId").Equal(true, "IsCurrent")).Select(bv => bv.Id).ToList(); syncName = "BudgetVersionId"; } else { syncIds = budgetIds.Cast<object>().ToList(); syncName = "BudgetId"; } foreach (var id in ids) { try { var sync = new UniversalSyncMain(formName, id, syncName, syncIds); sync.Sync(); } catch (Exception ex) { return new ContentResult() { Content = string.Format("{{\"success\":false,\"message\":\"{0}\"}}", HttpUtility.JavaScriptStringEncode(ex.Message)) }; } } return new ContentResult() { Content = string.Format("{{\"success\":true,\"message\":\"{0}\"}}", OptimaJet.Localization.LocalizationProvider.Provider.Get("Synchronization is successful!")) }; }