Ejemplo n.º 1
0
        public static string AddProtocol(ProtocolBE protocolBE, List <ProtocolComponentDto> ListProtCompCreate, int nodeId, int userId)
        {
            try
            {
                DatabaseContext cnx   = new DatabaseContext();
                var             newId = new Common.Utils().GetPrimaryKey(nodeId, 20, "PR");
                protocolBE.v_ProtocolId   = newId;
                protocolBE.i_IsDeleted    = (int)SiNo.No;
                protocolBE.d_InsertDate   = DateTime.Now;
                protocolBE.i_InsertUserId = userId;
                cnx.Protocol.Add(protocolBE);
                cnx.SaveChanges();

                var result = ProtocolComponentDal.AddProtocolComponent(ListProtCompCreate, newId, userId, nodeId);
                if (!result)
                {
                    return(null);
                }
                return(newId);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static string UpdateProtocol(ProtocolBE protocolBE, List <ProtocolComponentDto> ListProtCompCreate, List <ProtocolComponentDto> ListProtCompUpdate, int userId, int nodeId)
        {
            try
            {
                DatabaseContext cnx = new DatabaseContext();

                var objProtocol = cnx.Protocol.Where(x => x.v_ProtocolId == protocolBE.v_ProtocolId).FirstOrDefault();

                objProtocol.v_Name = protocolBE.v_Name;
                objProtocol.v_GroupOccupationId      = protocolBE.v_GroupOccupationId;
                objProtocol.v_CustomerOrganizationId = protocolBE.v_CustomerOrganizationId;
                objProtocol.v_CustomerLocationId     = protocolBE.v_CustomerLocationId;
                objProtocol.i_MasterServiceTypeId    = protocolBE.i_MasterServiceTypeId;
                objProtocol.v_EmployerOrganizationId = protocolBE.v_EmployerOrganizationId;
                objProtocol.v_EmployerLocationId     = protocolBE.v_EmployerLocationId;
                objProtocol.i_MasterServiceId        = protocolBE.i_MasterServiceId;
                objProtocol.v_WorkingOrganizationId  = protocolBE.v_WorkingOrganizationId;
                objProtocol.v_WorkingLocationId      = protocolBE.v_WorkingLocationId;
                objProtocol.v_CostCenter             = protocolBE.v_CostCenter;
                objProtocol.i_EsoTypeId        = protocolBE.i_EsoTypeId;
                objProtocol.i_IsActive         = protocolBE.i_IsActive;
                objProtocol.r_PriceFactor      = protocolBE.r_PriceFactor;
                objProtocol.r_HospitalBedPrice = protocolBE.r_HospitalBedPrice;
                objProtocol.r_DiscountExam     = protocolBE.r_DiscountExam;
                objProtocol.r_MedicineDiscount = protocolBE.r_MedicineDiscount;
                objProtocol.i_UpdateUserId     = userId;
                objProtocol.d_UpdateDate       = DateTime.Now;

                cnx.SaveChanges();
                if (ListProtCompCreate.Count > 0)
                {
                    var result = ProtocolComponentDal.AddProtocolComponent(ListProtCompCreate, objProtocol.v_ProtocolId, userId, nodeId);
                    if (!result)
                    {
                        return(null);
                    }
                }

                if (ListProtCompUpdate.Count > 0)
                {
                    var result = ProtocolComponentDal.UpdateProtocolComponent(ListProtCompUpdate, userId);
                    if (!result)
                    {
                        return(null);
                    }
                }


                return(objProtocol.v_ProtocolId);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }