Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
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);
            }
        }
        public OralConsultationItem GetOralConsultationItemByID(int oralConsultationID)
        {
            var oralConsultation = db.OralConsultations.Find(oralConsultationID);
            var issue            = db.Issues.Find(oralConsultation.IssueID);

            OralConsultationItem item = new OralConsultationItem
            {
                OralConsultationID      = oralConsultation.OralConsultationID,
                IssueID                 = issue.IssueID,
                IssueName               = issue.IssueName,
                IssueDate               = issue.IssueDate,
                IssueDescription        = issue.IssueDescription,
                OralConsultationDate    = oralConsultation.OralConsultationDate,
                InvocationTypeID        = oralConsultation.InvocationTypeID,
                TargetGroupID           = oralConsultation.TargetGroupID,
                ProblemDescription      = oralConsultation.ProblemDescription,
                ConsultationDescription = oralConsultation.ConsultationDescription,
                GUID = Guid.NewGuid(),
                InitializationType = InitializationTypes.Update,
                UserID             = String.Empty,
                ChangeDate         = null
            };

            foreach (var consultant in db.OralConsultationConsultants.Where(p => p.OralConsultationID == oralConsultationID))
            {
                TmpOralConsultationConsultant itm = new TmpOralConsultationConsultant();
                itm.OralConsultationConsultantID = consultant.OralConsultationConsultantID;
                itm.OralConsultationID           = consultant.OralConsultationID;
                itm.ConsultantID = consultant.ConsultantID;
                itm.GUID         = item.GUID;
                db.TmpOralConsultationConsultants.Add(itm);
            }

            foreach (var organization in db.OralConsultationOrganizations.Where(p => p.OralConsultationID == oralConsultationID))
            {
                TmpOralConsultationOrganization itm = new TmpOralConsultationOrganization();
                itm.OralConsultationOrganizationID = organization.OralConsultationOrganizationID;
                itm.OralConsultationID             = organization.OralConsultationID;
                itm.OrganizationID = organization.OrganizationID;
                itm.GUID           = item.GUID;
                db.TmpOralConsultationOrganizations.Add(itm);
            }

            foreach (var right in db.OralConsultationRights.Where(p => p.OralConsultationID == oralConsultationID))
            {
                TmpOralConsultationRight itm = new TmpOralConsultationRight();
                itm.OralConsultationRightID = right.OralConsultationRightID;
                itm.OralConsultationID      = right.OralConsultationID;
                itm.HumanRightID            = right.HumanRightID;
                itm.GUID = item.GUID;
                db.TmpOralConsultationRights.Add(itm);
            }

            foreach (var permission in db.OralConsultationPermissions.Where(p => p.OralConsultationID == oralConsultationID))
            {
                TmpOralConsultationPermission itm = new TmpOralConsultationPermission();
                itm.OralConsultationPermissionID = permission.OralConsultationPermissionID;
                itm.OralConsultationID           = permission.OralConsultationID;
                itm.UserID   = permission.UserID;
                itm.IsChange = permission.IsChange;
                itm.IsRead   = permission.IsRead;
                itm.GUID     = item.GUID;
                db.TmpOralConsultationPermissions.Add(itm);
            }

            db.SaveChanges();

            return(item);
        }