public virtual ActionResult Update(DispatchListsTable dispatchLists) { int resultado = 0; try { int dispatchID = DispatchLists.UPDDispatchLists(dispatchLists.Name, dispatchLists.DispatchListID); int RowCount = DispatchLists.DelDispatchLists(dispatchID); foreach (var account in dispatchLists.Accounts) { DispatchsItemsParameters objE = new DispatchsItemsParameters(); objE.AccountNumber = Convert.ToString(account.AccountID); objE.DispatchListID = dispatchID; resultado = DispatchItemsList.InsertDispatchListItems(objE); } } catch (Exception ex) { var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException); throw exception; } return(Json(new { result = (resultado == 0 ? false : true) })); }
public virtual ActionResult DeleteDispatchLists(List <int> items) { try { string resultado = string.Empty; using (TransactionScope trs = new TransactionScope(TransactionScopeOption.Required)) { foreach (var item in items) { DispatchListsTable entidad = new DispatchListsTable(); entidad.DispatchListID = item; resultado = DispatchLists.DeleteDispatch(entidad); if (resultado.Trim().Length > 0) { trs.Dispose(); return(Json(new { result = false, message = resultado })); } } trs.Complete(); } return(Json(new { result = true, message = "" })); } catch (Exception ex) { var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException); return(JsonError(exception.PublicMessage)); } }
public static DispatchListsTable GetDispatchListsByDispatchListID(int DispatchListID) { DispatchListsTable dispatch = DataAccess.ExecWithStoreProcedureListParam <DispatchListsTable>("Core", "uspGetDispatchListsByDispatchListID", new SqlParameter("DispatchListID", SqlDbType.Int) { Value = DispatchListID }).ToList()[0]; return(dispatch); }
public virtual ActionResult Save(DispatchListsTable dispatchLists) { int resultado = 0; try { if (dispatchLists.DispatchListID > 0) { resultado = DispatchLists.UpdateDispatch(dispatchLists); } else { using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required)) { int dispatchListID = DispatchLists.InsertDispatch(dispatchLists); if (dispatchListID < 1) { tran.Dispose(); return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch List" })); } foreach (var account in dispatchLists.Accounts) { DispatchsItemsParameters objE = new DispatchsItemsParameters(); objE.AccountNumber = Convert.ToString(account.AccountID); objE.DispatchListID = dispatchListID; if (DispatchItemsList.InsertDispatchListItems(objE) < 1) { tran.Dispose(); return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch List" })); } } resultado = 1; tran.Complete(); } } } catch (Exception ex) { var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException); throw exception; } return(Json(new { result = (resultado == 0 ? false : true) })); }
public static int InsertDispatch(DispatchListsTable entidad) { var result = DataAccess.ExecWithStoreProcedureScalarType <int>("Core", "uspInsertDispatchLists", new SqlParameter("Editable", SqlDbType.Int) { Value = 1 }, new SqlParameter("Name", SqlDbType.VarChar, 200) { Value = entidad.Name }, new SqlParameter("MarketID", SqlDbType.Int) { Value = 56 } ); return(result); }
public static string DeleteDispatch(DispatchListsTable entidad) { string resultado = string.Empty; using (SqlConnection connection = new SqlConnection(DataAccess.GetConnectionString("Core"))) { connection.Open(); using (SqlCommand command = connection.CreateCommand()) { command.CommandText = "dbo.uspDeleteDispatchLists"; command.CommandType = CommandType.StoredProcedure; SqlParameter DispatchID = command.Parameters.AddWithValue("@DispatchListID", entidad.DispatchListID); SqlParameter Error = command.Parameters.AddWithValue("@Error", ""); Error.Direction = ParameterDirection.Output; SqlDataReader dr = command.ExecuteReader(); resultado = Error.Value.ToString(); } } return(resultado); }