Пример #1
0
        public OralConsultationPermissionItem InsertPermission(OralConsultationPermissionItem item)
        {
            try
            {
                TmpOralConsultationPermission entity = new TmpOralConsultationPermission
                {
                    OralConsultationPermissionID = 0,
                    OralConsultationID           = item.OralConsultationID,
                    UserID   = item.UserID,
                    IsRead   = item.IsRead,
                    IsChange = item.IsChange,
                    GUID     = item.GUID
                };

                db.TmpOralConsultationPermissions.Add(entity);

                db.SaveChanges();

                item.ID = entity.ID;
                item.OralConsultationPermissionID = entity.OralConsultationPermissionID;
                AspNetUsers user = db.AspNetUsers.Find(item.UserID);
                item.UserName = user.FirstName + " " + user.LastName;

                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
Пример #2
0
        public OralConsultationPermissionItem UpdatePermission(OralConsultationPermissionItem item)
        {
            try
            {
                TmpOralConsultationPermission entity = new TmpOralConsultationPermission
                {
                    ID = item.ID,
                    OralConsultationPermissionID = item.OralConsultationPermissionID,
                    OralConsultationID           = item.OralConsultationID,
                    UserID   = item.UserID,
                    IsRead   = item.IsRead,
                    IsChange = item.IsChange,
                    GUID     = item.GUID
                };

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

                db.SaveChanges();

                AspNetUsers user = db.AspNetUsers.Find(item.UserID);
                item.UserName = user.FirstName + " " + user.LastName;
                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
Пример #3
0
        public OralConsultationPermissionItem DeletePermission(OralConsultationPermissionItem item)
        {
            try
            {
                TmpOralConsultationPermission entity = new TmpOralConsultationPermission
                {
                    ID = item.ID,
                    OralConsultationPermissionID = item.OralConsultationPermissionID,
                    OralConsultationID           = item.OralConsultationID,
                    UserID   = item.UserID,
                    IsRead   = item.IsRead,
                    IsChange = item.IsChange,
                    GUID     = item.GUID
                };

                db.TmpOralConsultationPermissions.Attach(entity);
                db.TmpOralConsultationPermissions.Remove(entity);

                db.SaveChanges();
                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }