public void AddMedicalExam(ref OperationResult pobjOperationResult, componentDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); component objEntity = componentAssembler.ToEntity(pobjDtoEntity); //var query = from A in dbContext.component var Result = (from A in dbContext.component where A.i_IsDeleted == 0 && A.v_Name == pobjDtoEntity.v_Name select A).FirstOrDefault(); if (Result != null) { pobjOperationResult.ErrorMessage = "El nombre ya se encuentra registrado"; pobjOperationResult.Success = 0; return; } 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, 17), "ME"); objEntity.v_ComponentId = NewId; dbContext.AddTocomponent(objEntity); dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO", "v_MedicalExamId=" + 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, "EXAMEN MÉDICO", "v_MedicalExamId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }