Exemple #1
0
        public ResponseResult AddNotice(NoticeVM noticeVM)//Add Or Update Notice
        {
            ResponseResult responseResult = new ResponseResult();

            System.Data.Entity.Core.Objects.ObjectParameter MSG_Code =
                new System.Data.Entity.Core.Objects.ObjectParameter("MSG_Code", typeof(string));
            System.Data.Entity.Core.Objects.ObjectParameter MSG =
                new System.Data.Entity.Core.Objects.ObjectParameter("MSG", typeof(string));
            try
            {
                _dbContext.AddNotice_SP(noticeVM.NoticeId, noticeVM.PostedBy, noticeVM.MaskingId, noticeVM.Message,
                                        noticeVM.Title, noticeVM.PostedDate, noticeVM.UpdatedDate,
                                        noticeVM.PostedForTime, MSG_Code, MSG);

                responseResult.MessageCode   = MSG_Code.Value.ToString();
                responseResult.SystemMessage = MSG.Value.ToString();
                responseResult.Content       = null;
            }
            catch (Exception ex)
            {
                responseResult.MessageCode   = MSG_Code.ToString();
                responseResult.SystemMessage = MSG.Value.ToString();
                responseResult.Content       = null;
                //throw ex;
            }
            return(responseResult);
        }
Exemple #2
0
        public ResponseResult AssignTeacherSubjectWithPeriodOrtUpdate(AssignTeachersSubjectWithPeriodVM assignTeachersSubjectWithPeriodVM)
        {
            ResponseResult responseResult = new ResponseResult();

            System.Data.Entity.Core.Objects.ObjectParameter MSG_Code =
                new System.Data.Entity.Core.Objects.ObjectParameter("MSG_Code", typeof(string));
            System.Data.Entity.Core.Objects.ObjectParameter MSG =
                new System.Data.Entity.Core.Objects.ObjectParameter("MSG", typeof(string));

            try
            {
                Period periodObj = new Period()
                {
                    PeriodId         = assignTeachersSubjectWithPeriodVM.PeriodId,
                    MaskingSubjectId = GetSubjectMaskingIdBySubjactid(assignTeachersSubjectWithPeriodVM.SubjectId)
                };

                _dbContext.AddOrUpdateRoutineAssignment_SP(periodObj.MaskingSubjectId,
                                                           periodObj.PeriodId,
                                                           MSG_Code, MSG);
                responseResult.MessageCode   = MSG_Code.Value.ToString();
                responseResult.SystemMessage = MSG.Value.ToString();
                responseResult.Content       = null;
            }
            catch (Exception)
            {
                responseResult.MessageCode   = MSG_Code.ToString();
                responseResult.SystemMessage = MSG.Value.ToString();
                responseResult.Content       = null;
            }
            return(responseResult);
        }
Exemple #3
0
        public static int AddUserByUID(string strUser, Int32 intAPPID)
        {
            Int32 intASID = 0;

            RexrothEntities db        = clsStart.efdbRexroth();
            string          strDomain = "";

            System.Data.Entity.Core.Objects.ObjectParameter pk = new System.Data.Entity.Core.Objects.ObjectParameter("PK", typeof(int));

            System.Data.Entity.Core.Objects.ObjectParameter error = new System.Data.Entity.Core.Objects.ObjectParameter("EMessage", typeof(string));
            Cursor.Current = Cursors.WaitCursor;

            var lstDomains = new string[] { "US", "DE", "MX" };

            if (!(UserExists(strUser)))
            {
                foreach (string strDom in lstDomains)
                {
                    try
                    {
                        //var qry = (from ct in db.tblApp
                        //           where ct.APPID == intAPPID
                        //           select ct).FirstOrDefault();

                        PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, strDom);


                        UserPrincipal user = new UserPrincipal(domainContext);

                        //Specify the search parameters
                        user.Name = strUser;

                        PrincipalSearcher pS = new PrincipalSearcher();
                        pS.QueryFilter = user;

                        PrincipalSearchResult <Principal> results = pS.FindAll();


                        //If necessary, request more details
                        //Principal pc = results.ToList()[0];
                        //DirectoryEntry de = (DirectoryEntry)pc.GetUnderlyingObject();

                        if (results.ToList().Count > 0)
                        {
                            foreach (UserPrincipal usr in results)
                            {
                                //tblAssociate tbl = new tblAssociate();



                                //ObjectParameter name = new ObjectParameter("Name", typeof(String));
                                db.p_SaveChangesEF(usr.GivenName, usr.Surname, usr.SamAccountName, usr.EmailAddress.ToString(), usr.DisplayName, pk, error);

                                if (Convert.ToInt32(pk.Value) == 0)
                                {
                                    MessageBox.Show(error.ToString());
                                }

                                else
                                {
                                    Cursor.Current = Cursors.Default;
                                    MessageBox.Show(usr.DisplayName + " added!", "Credo");
                                }
                            }
                        }
                        else
                        {
                            Cursor.Current = Cursors.Default;
                            MessageBox.Show(strUser + " not found.", "Credo");
                        }
                    }
                    catch (Exception ex)
                    {
                        Cursor.Current = Cursors.Default;
                        MessageBox.Show(ex.Message, "Credo");
                    }
                }
            }
            else
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(strUser + " already exists.", "Credo");
            }
            Cursor.Current = Cursors.Default;

            intASID = Convert.ToInt32(pk.Value);
            return(intASID);
        }