Ejemplo n.º 1
0
        public TargetGroupDetail Put(TargetGroupDetailDTO obj)
        {
            TargetGroupDetail targetGroupDetail = new TargetGroupDetail();

            //targetGroupDetail = obj.Map<TargetGroupDetail>();
            SessionManager.DoWork(session =>
            {
                if (obj.Id == Guid.Empty)
                {
                    targetGroupDetail.Id = Guid.NewGuid();
                }
                else
                {
                    targetGroupDetail              = session.Query <TargetGroupDetail>().Where(t => t.Id == obj.Id).SingleOrDefault();
                    targetGroupDetail.Name         = obj.Name;
                    targetGroupDetail.Density      = obj.Density;
                    targetGroupDetail.AgentObjects = new List <AgentObject>();
                }

                foreach (var id in obj.AgentObjectIds)
                {
                    targetGroupDetail.AgentObjects.Add(new AgentObject()
                    {
                        Id = id
                    });
                }
                session.SaveOrUpdate(targetGroupDetail);
            });
            //SessionManager.DoWork(session => session.SaveOrUpdate(obj));
            return(targetGroupDetail);
        }
Ejemplo n.º 2
0
        public TargetGroupDetailDTO GetTargetGroupDetailNameByCriterion(Guid id)
        {
            TargetGroupDetailDTO result = new TargetGroupDetailDTO();

            SessionManager.DoWork(session =>
            {
                ProfessorCriterion cri = session.Query <ProfessorCriterion>().SingleOrDefault(a => a.Id == id);
                if (cri != null)
                {
                    result.Id   = cri.TargetGroupDetail.Id;
                    result.Name = cri.TargetGroupDetail.Name;
                    result.TargetGroupDetailTypeId = cri.TargetGroupDetail.TargetGroupDetailType.Id;
                }
            });
            return(result);
        }
Ejemplo n.º 3
0
        public IEnumerable <TargetGroupDetailDTO> GetListTargetGroupDetail()
        {
            List <TargetGroupDetailDTO> result = new List <TargetGroupDetailDTO>();

            SessionManager.DoWork(session =>
            {
                List <TargetGroupDetail> list = new List <TargetGroupDetail>();
                //Lấy nhóm 2 và 3 của phòng ban, nhân viên
                list = session.Query <TargetGroupDetail>().Where(t => t.Id == new Guid("1FEC7670-B91E-4E24-AC68-45E270CECED3") || t.Id == new Guid("37A429BF-B53C-482E-AA33-9DDB17604558")).ToList();
                foreach (TargetGroupDetail t in list)
                {
                    TargetGroupDetailDTO td = new TargetGroupDetailDTO();
                    td.Id   = t.Id;
                    td.Name = t.Name;
                    result.Add(td);
                }
            });
            return(result);
        }
Ejemplo n.º 4
0
        public TargetGroupDetailDTO GetObj(Guid id)
        {
            TargetGroupDetailDTO result = new TargetGroupDetailDTO();

            SessionManager.DoWork(session =>
            {
                TargetGroupDetail tgd = session.Query <TargetGroupDetail>().SingleOrDefault(a => a.Id == id);
                if (tgd != null)
                {
                    result = tgd.Map <TargetGroupDetailDTO>();
                    result.AgentObjectIds = new List <Guid>();
                    foreach (AgentObject ag in tgd.AgentObjects)
                    {
                        result.AgentObjectIds.Add(ag.Id);
                    }
                    //result.TargetGroupId = result.TargetGroup.Id;
                }
            });
            return(result);
        }
Ejemplo n.º 5
0
        public IEnumerable <TargetGroupDetailDTO> GetListbyId(Guid classId)
        {
            List <TargetGroupDetailDTO> result = new List <TargetGroupDetailDTO>();

            SessionManager.DoWork(session =>
            {
                if (classId == Guid.Empty)
                {
                    List <TargetGroupDetail> tglist = new List <TargetGroupDetail>();
                    tglist = session.Query <TargetGroupDetail>().ToList();
                    foreach (TargetGroupDetail tg in tglist)
                    {
                        TargetGroupDetailDTO tgd = new TargetGroupDetailDTO();
                        tgd.Id                      = tg.Id;
                        tgd.Name                    = tg.Name;
                        tgd.Density                 = tg.Density;
                        tgd.OrderNumber             = tg.OrderNumber;
                        tgd.TargetGroupDetailTypeId = tg.TargetGroupDetailType != null ? tg.TargetGroupDetailType.Id : 0;
                        result.Add(tgd);
                    }
                }
                else
                {
                    List <TargetGroupDetail> tglist = new List <TargetGroupDetail>();
                    tglist = session.Query <TargetGroupDetail>().Where(a => a.AgentObjects.Any(ag => ag.Id == classId)).ToList();
                    foreach (TargetGroupDetail tg in tglist)
                    {
                        TargetGroupDetailDTO tgd = new TargetGroupDetailDTO();
                        tgd.Id                      = tg.Id;
                        tgd.Name                    = tg.Name;
                        tgd.Density                 = tg.Density;
                        tgd.OrderNumber             = tg.OrderNumber;
                        tgd.TargetGroupDetailTypeId = tg.TargetGroupDetailType != null ? tg.TargetGroupDetailType.Id : 0;
                        result.Add(tgd);
                    }
                }
            });
            return(result);
        }