public locationDto GetLocation(ref OperationResult pobjOperationResult, string pstrLocationId) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); locationDto objDtoEntity = null; var objEntity = (from a in dbContext.location where a.v_LocationId == pstrLocationId select a).FirstOrDefault(); if (objEntity != null) { objDtoEntity = locationAssembler.ToDTO(objEntity); } pobjOperationResult.Success = 1; return(objDtoEntity); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); return(null); } }
protected void btnSaveRefresh_Click(object sender, EventArgs e) { var locationId = ""; string Mode = Request.QueryString["Mode"].ToString(); OperationResult objOperationResult = new OperationResult(); if (Mode == "New") { // Create the entity locationDto objEntity = new locationDto(); // Populate the entity objEntity.v_OrganizationId = Session["v_OrganizationId"].ToString(); objEntity.v_Name = txtSede.Text; // Save the data locationId = oOrganizationBL.AddLocation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList()); //Rutina para Asignar la Empresa creada automaticamente al nodo actual NodeOrganizationLoactionWarehouseList objNodeOrganizationLoactionWarehouseList = new NodeOrganizationLoactionWarehouseList(); List <nodeorganizationlocationwarehouseprofileDto> objnodeorganizationlocationwarehouseprofileDto = new List <nodeorganizationlocationwarehouseprofileDto>(); //Llenar Entidad Empresa/sede objNodeOrganizationLoactionWarehouseList.i_NodeId = 9; objNodeOrganizationLoactionWarehouseList.v_OrganizationId = Session["v_OrganizationId"].ToString(); objNodeOrganizationLoactionWarehouseList.v_LocationId = locationId; //Llenar Entidad Almacén var objInsertWarehouseList = InsertWarehouse(locationId); oOrganizationBL.AddNodeOrganizationLoactionWarehouse(ref objOperationResult, objNodeOrganizationLoactionWarehouseList, objInsertWarehouseList, ((ClientSession)Session["objClientSession"]).GetAsList()); } else if (Mode == "Edit") { locationDto objEntity = new locationDto(); // Populate the entity objEntity.v_OrganizationId = Session["v_OrganizationId"].ToString(); objEntity.v_LocationId = Session["v_LocationId"].ToString(); objEntity.v_Name = txtSede.Text; oOrganizationBL.UpdateLocation(ref objOperationResult, objEntity, ((ClientSession)Session["objClientSession"]).GetAsList()); } //Analizar el resultado de la operación if (objOperationResult.Success == 1) // Operación sin error { // Cerrar página actual y hacer postback en el padre para actualizar PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else // Operación con error { Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage); // Se queda en el formulario. } }
public string UpdateLocation(ref OperationResult pobjOperationResult, locationDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); // Obtener la entidad fuente var objEntitySource = (from a in dbContext.location where a.v_LocationId == pobjDtoEntity.v_LocationId select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); location objEntity = locationAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.location.ApplyCurrentValues(objEntity); // Guardar los cambios dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "SEDE", "v_LocationId=" + objEntity.v_LocationId.ToString(), Success.Ok, null); return(objEntity.v_LocationId); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "SEDE", "v_LocationId=" + pobjDtoEntity.v_LocationId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return(null); } }
public string AddLocation(ref OperationResult pobjOperationResult, locationDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); location objEntity = locationAssembler.ToEntity(pobjDtoEntity); objEntity.d_InsertDate = DateTime.Now; objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]); objEntity.i_IsDeleted = 0; // Autogeneramos el Pk de la tabla int intNodeId = int.Parse(ClientSession[0]); NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 14), "OL"); objEntity.v_LocationId = NewId; dbContext.AddTolocation(objEntity); dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "SEDE", "v_LocationId=" + NewId.ToString(), Success.Ok, null); return(NewId); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "SEDE", "v_LocationId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return(null); } }