Beispiel #1
0
        public TypeConsultationPermissionItem InsertPermission(TypeConsultationPermissionItem item)
        {
            try
            {
                TmpTypeConsultationPermission entity = new TmpTypeConsultationPermission
                {
                    TypeConsultationPermissionID = 0,
                    TypeConsultationID           = item.TypeConsultationID,
                    UserID   = item.UserID,
                    IsRead   = item.IsRead,
                    IsChange = item.IsChange,
                    GUID     = item.GUID
                };

                db.TmpTypeConsultationPermissions.Add(entity);

                db.SaveChanges();

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

                return(item);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(null);
            }
        }
Beispiel #2
0
        public TypeConsultationPermissionItem UpdatePermission(TypeConsultationPermissionItem item)
        {
            try
            {
                TmpTypeConsultationPermission entity = new TmpTypeConsultationPermission
                {
                    ID = item.ID,
                    TypeConsultationPermissionID = item.TypeConsultationPermissionID,
                    TypeConsultationID           = item.TypeConsultationID,
                    UserID   = item.UserID,
                    IsRead   = item.IsRead,
                    IsChange = item.IsChange,
                    GUID     = item.GUID
                };

                db.TmpTypeConsultationPermissions.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);
            }
        }
Beispiel #3
0
        public TypeConsultationPermissionItem DeletePermission(TypeConsultationPermissionItem item)
        {
            try
            {
                TmpTypeConsultationPermission entity = new TmpTypeConsultationPermission
                {
                    ID = item.ID,
                    TypeConsultationPermissionID = item.TypeConsultationPermissionID,
                    TypeConsultationID           = item.TypeConsultationID,
                    UserID   = item.UserID,
                    IsRead   = item.IsRead,
                    IsChange = item.IsChange,
                    GUID     = item.GUID
                };

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

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