Exemplo n.º 1
0
        public string AddMedicalExamFields(ref OperationResult pobjOperationResult, componentfieldDto pobjDtoEntity, componentfieldsDto pobjDtoEntitys, string pstrComponentId, List <string> ClientSession)
        {
            //mon.IsActive = true;
            string NewId = "(No generado)";

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                var query1 = (from a in dbContext.componentfield
                              join b in dbContext.componentfields on a.v_ComponentFieldId equals b.v_ComponentFieldId
                              where a.v_TextLabel.ToUpper() == pobjDtoEntity.v_TextLabel.ToUpper() && b.v_ComponentId == pobjDtoEntitys.v_ComponentId && b.v_Group == pobjDtoEntitys.v_Group
                              select a).ToList();
                if (query1.Count > 0)
                {
                    pobjOperationResult.ErrorMessage = "Nombre del componente duplicado";
                    return("0");
                }
                #region ComponentField
                componentfield objEntity = componentfieldAssembler.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, 18), "MF");

                objEntity.v_ComponentFieldId = NewId;



                dbContext.AddTocomponentfield(objEntity);
                dbContext.SaveChanges();
                #endregion

                #region ComponentFields
                componentfields objEntitys = componentfieldsAssembler.ToEntity(pobjDtoEntitys);
                objEntitys.v_ComponentFieldId = NewId;
                objEntitys.v_ComponentId      = pstrComponentId;
                objEntitys.d_InsertDate       = DateTime.Now;
                objEntitys.i_InsertUserId     = Int32.Parse(ClientSession[2]);
                objEntitys.i_IsDeleted        = 0;

                dbContext.AddTocomponentfields(objEntitys);
                dbContext.SaveChanges();

                #endregion

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO CAMPO", "v_MedicalExamFieldsId=" + 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, "EXAMEN MÉDICO CAMPO", "v_MedicalExamFieldsId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return("0");
            }
        }