Ejemplo n.º 1
0
        public ScienceResearchDTO GetObj(Guid id)
        {
            var result = new ScienceResearchDTO();

            SessionManager.DoWork(session =>
            {
                ScienceResearch sr = session.Query <ScienceResearch>().SingleOrDefault(a => a.Id == id);
                if (sr != null)
                {
                    result.Id                    = sr.Id;
                    result.Name                  = sr.Name;
                    result.PlanKPIDetailId       = sr.PlanKPIDetail != null ? sr.PlanKPIDetail.Id : Guid.Empty;
                    result.CriterionDictionaryId = sr.CriterionDictionary != null ? sr.CriterionDictionary.Id : Guid.Empty;
                    result.NumberOfResearch      = sr.NumberOfResearch;
                    result.OrderNumber           = sr.OrderNumber;
                    result.IsRating              = sr.IsRating;
                }
            });
            return(result);
        }
Ejemplo n.º 2
0
        public int Put(ScienceResearchDTO obj)
        {
            int result = 0;

            //try
            //{
            SessionManager.DoWork(session =>
            {
                if (obj.CriterionDictionaryId == Guid.Empty)
                {
                    if (obj.Id == Guid.Empty)
                    {
                        ScienceResearch pa = new ScienceResearch();
                        pa.Id               = Guid.NewGuid();
                        pa.Name             = obj.Name;
                        pa.NumberOfResearch = obj.NumberOfResearch;
                        pa.OrderNumber      = obj.OrderNumber;
                        pa.IsRating         = obj.IsRating;
                        pa.PlanKPIDetail    = new PlanKPIDetail()
                        {
                            Id = obj.PlanKPIDetailId
                        };
                        pa.CriterionDictionary = null;
                        session.Save(pa);
                    }
                    else
                    {
                        ScienceResearch pa = new ScienceResearch();
                        pa.Id               = obj.Id;
                        pa.Name             = obj.Name;
                        pa.NumberOfResearch = obj.NumberOfResearch;
                        pa.OrderNumber      = obj.OrderNumber;
                        pa.IsRating         = obj.IsRating;
                        pa.PlanKPIDetail    = new PlanKPIDetail()
                        {
                            Id = obj.PlanKPIDetailId
                        };
                        pa.CriterionDictionary = null;
                        session.Update(pa);
                    }
                }
                else
                {
                    ScienceResearch pa = new ScienceResearch();
                    pa.Id               = obj.Id;
                    pa.Name             = obj.Name;
                    pa.NumberOfResearch = obj.NumberOfResearch;
                    pa.IsRating         = obj.IsRating;
                    pa.PlanKPIDetail    = new PlanKPIDetail()
                    {
                        Id = obj.PlanKPIDetailId
                    };
                    pa.CriterionDictionary = new CriterionDictionary()
                    {
                        Id = obj.CriterionDictionaryId
                    };
                    session.Update(pa);
                }
                result = 1;
            });
            //}
            //catch (Exception e)
            //{
            //    result = 0;
            //}
            return(result);
        }
Ejemplo n.º 3
0
 public ScienceResearch Delete(ScienceResearch obj)
 {
     SessionManager.DoWork(session => session.Delete(obj));
     return(obj);
 }