public void AddGES(ref OperationResult pobjOperationResult, gesDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); ges objEntity = gesAssembler.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, 12), "OE");; objEntity.v_GesId = NewId; dbContext.AddToges(objEntity); dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "GES", "v_GesId=" + NewId.ToString(), Success.Ok, null); return; } 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, "GES", "v_GesId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
/// <summary> /// Converts this instance of <see cref="ges"/> to an instance of <see cref="gesDto"/>. /// </summary> /// <param name="entity"><see cref="ges"/> to convert.</param> public static gesDto ToDTO(this ges entity) { if (entity == null) { return(null); } var dto = new gesDto(); dto.v_GesId = entity.v_GesId; dto.v_AreaId = entity.v_AreaId; dto.v_Name = entity.v_Name; dto.i_IsDeleted = entity.i_IsDeleted; dto.i_InsertUserId = entity.i_InsertUserId; dto.d_InsertDate = entity.d_InsertDate; dto.i_UpdateUserId = entity.i_UpdateUserId; dto.d_UpdateDate = entity.d_UpdateDate; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="gesDto"/> to an instance of <see cref="ges"/>. /// </summary> /// <param name="dto"><see cref="gesDto"/> to convert.</param> public static ges ToEntity(this gesDto dto) { if (dto == null) { return(null); } var entity = new ges(); entity.v_GesId = dto.v_GesId; entity.v_AreaId = dto.v_AreaId; entity.v_Name = dto.v_Name; entity.i_IsDeleted = dto.i_IsDeleted; entity.i_InsertUserId = dto.i_InsertUserId; entity.d_InsertDate = dto.d_InsertDate; entity.i_UpdateUserId = dto.i_UpdateUserId; entity.d_UpdateDate = dto.d_UpdateDate; dto.OnEntity(entity); return(entity); }
public void UpdateGES(ref OperationResult pobjOperationResult, gesDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); // Obtener la entidad fuente var objEntitySource = (from a in dbContext.ges where a.v_GesId == pobjDtoEntity.v_GesId select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); ges objEntity = gesAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.ges.ApplyCurrentValues(objEntity); // Guardar los cambios dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "GES", "v_GesId=" + objEntity.v_GesId.ToString(), Success.Ok, null); return; } 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, "GES", "v_GesId=" + pobjDtoEntity.v_GesId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="ges"/> converted from <see cref="gesDto"/>.</param> static partial void OnEntity(this gesDto dto, ges entity);
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="gesDto"/> converted from <see cref="ges"/>.</param> static partial void OnDTO(this ges entity, gesDto dto);