/// <summary> /// Converts this instance of <see cref="serviceorderdetail"/> to an instance of <see cref="serviceorderdetailDto"/>. /// </summary> /// <param name="entity"><see cref="serviceorderdetail"/> to convert.</param> public static serviceorderdetailDto ToDTO(this serviceorderdetail entity) { if (entity == null) { return(null); } var dto = new serviceorderdetailDto(); dto.v_ServiceOrderDetailId = entity.v_ServiceOrderDetailId; dto.v_ServiceOrderId = entity.v_ServiceOrderId; dto.v_ProtocolId = entity.v_ProtocolId; 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; dto.r_ProtocolPrice = entity.r_ProtocolPrice; dto.i_NumberOfWorkerProtocol = entity.i_NumberOfWorkerProtocol; dto.r_Total = entity.r_Total; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="serviceorderdetailDto"/> to an instance of <see cref="serviceorderdetail"/>. /// </summary> /// <param name="dto"><see cref="serviceorderdetailDto"/> to convert.</param> public static serviceorderdetail ToEntity(this serviceorderdetailDto dto) { if (dto == null) { return(null); } var entity = new serviceorderdetail(); entity.v_ServiceOrderDetailId = dto.v_ServiceOrderDetailId; entity.v_ServiceOrderId = dto.v_ServiceOrderId; entity.v_ProtocolId = dto.v_ProtocolId; 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; entity.r_ProtocolPrice = dto.r_ProtocolPrice; entity.i_NumberOfWorkerProtocol = dto.i_NumberOfWorkerProtocol; entity.r_Total = dto.r_Total; dto.OnEntity(entity); return(entity); }
public string AddServiceOrder(ref OperationResult pobjOperationResult, serviceorderDto pobjDtoEntity, List <serviceorderdetailDto> pobjDtoEntityDetail, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); #region Service Order serviceorder objEntity = serviceorderAssembler.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, 101), "YY"); objEntity.v_ServiceOrderId = NewId; dbContext.AddToserviceorder(objEntity); dbContext.SaveChanges(); #endregion #region Service Order Detail if (pobjDtoEntityDetail != null) { foreach (var item in pobjDtoEntityDetail) { serviceorderdetail objEntityDetail = serviceorderdetailAssembler.ToEntity(item); objEntityDetail.d_InsertDate = DateTime.Now; objEntityDetail.i_InsertUserId = Int32.Parse(ClientSession[2]); objEntityDetail.i_IsDeleted = 0; // Autogeneramos el Pk de la tabla objEntityDetail.v_ServiceOrderId = NewId; objEntityDetail.v_ServiceOrderDetailId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 102), "YA"); dbContext.AddToserviceorderdetail(objEntityDetail); dbContext.SaveChanges(); } } pobjOperationResult.Success = 1; #endregion // Llenar entidad Log //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "ORDERN SERVICIO", "v_ServiceOrderId=" + 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, "ORDEN SERVICIO", "v_ServiceOrderId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return(null); } }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="serviceorderdetail"/> converted from <see cref="serviceorderdetailDto"/>.</param> static partial void OnEntity(this serviceorderdetailDto dto, serviceorderdetail entity);
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="serviceorderdetailDto"/> converted from <see cref="serviceorderdetail"/>.</param> static partial void OnDTO(this serviceorderdetail entity, serviceorderdetailDto dto);
public void UpdateService(ref OperationResult pobjOperationResult, serviceorderDto pobjDtoEntity, List <serviceorderdetailDto> pobjDtoEntityDetail, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); #region ServiceOrder // Obtener la entidad fuente var objEntitySource = (from a in dbContext.serviceorder where a.v_ServiceOrderId == pobjDtoEntity.v_ServiceOrderId && a.i_IsDeleted == 0 select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); serviceorder objEntity = serviceorderAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.serviceorder.ApplyCurrentValues(objEntity); #endregion #region ServiceOrderDetail // Obtener la entidad fuente List <serviceorderdetail> pobjserviceorderdetailList = new List <serviceorderdetail>(); var objEntitySourceDetail = (from a in dbContext.serviceorderdetail where a.v_ServiceOrderId == pobjDtoEntity.v_ServiceOrderId select a).ToList(); foreach (var item in objEntitySourceDetail) { dbContext.serviceorderdetail.DeleteObject(item); dbContext.SaveChanges(); } if (pobjDtoEntityDetail != null) { int intNodeId = int.Parse(ClientSession[0]); foreach (var item in pobjDtoEntityDetail) { serviceorderdetail objDetailEntity = serviceorderdetailAssembler.ToEntity(item); if (item.v_ServiceOrderDetailId == null) { objDetailEntity.v_ServiceOrderDetailId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 102), "YA"); } else { objDetailEntity.v_ServiceOrderDetailId = item.v_ServiceOrderDetailId; } objDetailEntity.v_ProtocolId = item.v_ProtocolId; objDetailEntity.v_ServiceOrderId = pobjDtoEntity.v_ServiceOrderId; objDetailEntity.r_ProtocolPrice = item.r_ProtocolPrice; objDetailEntity.i_NumberOfWorkerProtocol = item.i_NumberOfWorkerProtocol; objDetailEntity.i_IsDeleted = 0; objDetailEntity.d_UpdateDate = DateTime.Now; objDetailEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); // Agregar el detalle del movimiento a la BD dbContext.AddToserviceorderdetail(objDetailEntity); } // Guardar los cambios dbContext.SaveChanges(); } #endregion pobjOperationResult.Success = 1; // Llenar entidad Log //LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "ORDEN SERVICIO", "v_ServiceOrderId=" + objEntity.v_ServiceOrderId.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, "SERVICIO", "v_ServiceOrderId=" + pobjDtoEntity.v_ServiceOrderId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }