public TypeConsultationRightItem UpdateRight(TypeConsultationRightItem item)
        {
            try
            {
                TmpTypeConsultationRight entity = new TmpTypeConsultationRight
                {
                    ID = item.ID,
                    TypeConsultationRightID = item.TypeConsultationRightID,
                    TypeConsultationID      = item.TypeConsultationID,
                    HumanRightID            = item.HumanRightID,
                    GUID = item.GUID
                };

                db.TmpTypeConsultationRights.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;

                db.SaveChanges();

                HumanRight humanRight = db.HumanRights.Find(item.HumanRightID);
                item.HumanRightName = humanRight.HumanRightName;
                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
        public TypeConsultationRightItem InsertRight(TypeConsultationRightItem item)
        {
            try
            {
                TmpTypeConsultationRight entity = new TmpTypeConsultationRight
                {
                    TypeConsultationRightID = 0,
                    TypeConsultationID      = item.TypeConsultationID,
                    HumanRightID            = item.HumanRightID,
                    GUID = item.GUID
                };

                db.TmpTypeConsultationRights.Add(entity);

                db.SaveChanges();

                item.ID = entity.ID;
                item.TypeConsultationRightID = entity.TypeConsultationRightID;
                HumanRight humanRight = db.HumanRights.Find(item.HumanRightID);
                item.HumanRightName = humanRight.HumanRightName;

                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
Example #3
0
        public void DeleteHumanRight(HumanRightItem humanRightItem)
        {
            var entity = new HumanRight
            {
                HumanRightID = humanRightItem.HumanRightID
            };

            db.HumanRights.Attach(entity);
            db.HumanRights.Remove(entity);
            db.SaveChanges();
        }
Example #4
0
        public void CreateHumanRight(HumanRightItem humanRightItem)
        {
            var entity = new HumanRight
            {
                HumanRightName = humanRightItem.HumanRightName
            };

            db.HumanRights.Add(entity);
            db.SaveChanges();
            humanRightItem.HumanRightID = entity.HumanRightID;
        }
Example #5
0
        public void UpdateHumanRight(HumanRightItem humanRightItem)
        {
            var entity = new HumanRight
            {
                HumanRightID   = humanRightItem.HumanRightID,
                HumanRightName = humanRightItem.HumanRightName
            };

            db.HumanRights.Attach(entity);
            db.Entry(entity).State = EntityState.Modified;
            db.SaveChanges();
        }