Beispiel #1
0
    IEnumerator PostRegister(string _email, string _password)
    {
        WWWForm form = new WWWForm();

        form.AddField("email", _email);
        form.AddField("password", _password);

        UnityWebRequest call_register = UnityWebRequest.Post("http://localhost:8000/api/register", form);

        yield return(call_register.Send());

        if (call_register.error != null)
        {
            Debug.Log("Error : " + call_register.error);
        }
        else
        {
            Debug.Log("Response : " + call_register.downloadHandler.text);

            RegisterDetail registerDetail = JsonUtility.FromJson <RegisterDetail> (call_register.downloadHandler.text);
            print(registerDetail.success);
            if (registerDetail.success)
            {
                SceneManager.LoadScene("Login");
            }
        }
    }
        public RegisterDetail RegisterClient(RegisterDetail request)
        {
            string         responseMessage, passwordResetUrl, contactId, webRoleId;
            RegisterDetail response = new RegisterDetail();

            _unitOfWork.RegisterClient(request.InvitationCode, request.FirstName, request.LastName, request.Email, out responseMessage, out passwordResetUrl,
                                       out contactId, out webRoleId);

            response.InvitationCode      = request.InvitationCode;
            response.FirstName           = request.FirstName;
            response.LastName            = request.LastName;
            response.Email               = request.Email;
            response.ContactId           = contactId;
            response.WebRoleId           = webRoleId;
            response.ResponseMessage     = responseMessage;
            response.PasswordResetUrl    = passwordResetUrl;
            response.SmtpServerIP        = "";
            response.SmtpServerPort      = 0;
            response.SmtpServerUsername  = "";
            response.SmtpServerPassword  = "";
            response.EmailObject         = new EmailMessage();
            response.EmailObject.From    = "";
            response.EmailObject.To      = "";
            response.EmailObject.Subject = "";
            response.EmailObject.Body    = "";
            return(response);
        }
Beispiel #3
0
        //void gridView_SelectionChanged(object sender, EventArgs e)
        //{
        //    if (SecuritySystem.CurrentUser is Student)
        //    {
        //        Student student = SecuritySystem.CurrentUser as Student;
        //        string currentClass = student.StudentClass.ClassCode;

        //        ASPxGridView gc = sender as ASPxGridView;

        //        List<Vacancy> tempList = new List<Vacancy>(listVacancies);

        //        List<object> listobj = gc.GetSelectedFieldValues(new string[] { "LessonCode" });
        //        ObjectSpace objectSpace = Application.CreateObjectSpace();

        //        Vacancy vc;
        //        string strFilter = "", strInclude = "";
        //        foreach (int strLessonCode in listobj)
        //        {
        //            Lesson lesson = objectSpace.FindObject<Lesson>(new BinaryOperator("LessonCode", strLessonCode));
        //            strInclude += String.Format("OR ([LessonCode]={0})", lesson.LessonCode);
        //            foreach (TkbSemester tkbsem in lesson.TKBSemesters)
        //            {
        //                vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
        //                tempList.Add(vc);
        //            }
        //        }
        //        if (strInclude != "")
        //            strInclude = String.Format("({0})", strInclude.Substring(3));

        //        if (listobj.Count > 0)
        //        {
        //            using (XPCollection xpLesson = new XPCollection(objectSpace.Session, typeof(Lesson)))
        //            {

        //                foreach (Lesson lesson in xpLesson)
        //                {
        //                    foreach (TkbSemester tkbsem in lesson.TKBSemesters)
        //                    {
        //                        vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
        //                        if (Utils.IsConfictTKB(tempList, vc))
        //                        {
        //                            strFilter += String.Format("AND ([LessonCode]<>{0})", lesson.LessonCode);
        //                            break;
        //                        }
        //                    }
        //                }
        //                if (strFilter != "")
        //                    strFilter = String.Format("({0})", strFilter.Substring(4));

        //            }
        //        }
        //        if (strInclude != "" && strFilter != "")
        //        {
        //            strFilter = String.Format("({0} OR {1})", strFilter, strInclude);
        //        }
        //        else if (strInclude != "")
        //        {
        //            strFilter = strInclude;

        //        }

        //        if (strFilter != "")
        //        {
        //            if (gc.FilterExpression.Contains("TkbLesson.ClassIDs"))
        //            {
        //                gc.FilterExpression = string.Format("([TkbLesson.ClassIDs] Like '%{0}%') AND {1}", currentClass, strFilter);
        //            }
        //            else
        //            {
        //                gc.FilterExpression = strFilter;
        //            }
        //        }

        //    }
        //}

        //void gridView_DataBound(object sender, EventArgs e)
        //{
        //    if (SecuritySystem.CurrentUser is Student)
        //    {
        //        Student student = SecuritySystem.CurrentUser as Student;
        //        string currentClass = student.StudentClass.ClassCode;
        //        ASPxGridView gc = sender as ASPxGridView;
        //        if (gc.FilterExpression == "")
        //            gc.FilterExpression = string.Format("[TkbLesson.ClassIDs] Like '%{0}%'", currentClass);
        //    }
        //}

        void selectAcception_AcceptingStudent(object sender, DialogControllerAcceptingEventArgs e)
        {
            if (SecuritySystem.CurrentUser is Student)
            {
                ObjectSpace objectSpace           = Application.CreateObjectSpace();
                DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
                if (SecuritySystem.CurrentUser is Student)
                {
                    objectSpace.Session.BeginTransaction();
                    Student student        = SecuritySystem.CurrentUser as Student;
                    Student currentStudent = objectSpace.FindObject <Student>(
                        new BinaryOperator("StudentCode", student.StudentCode));
                    Lesson curLesson;
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        curLesson = objectSpace.FindObject <Lesson>(
                            new BinaryOperator("Oid", lesson.Oid));
                        RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                        {
                            Student       = currentStudent,
                            Lesson        = curLesson,
                            RegisterState = objectSpace.FindObject <RegisterState>(
                                new BinaryOperator("Code", "SELECTED")),
                            CheckState = objectSpace.FindObject <RegisterState>(
                                new BinaryOperator("Code", "NOTCHECKED"))
                        };
                    }
                    objectSpace.Session.CommitTransaction();
                    //               View.ObjectSpace.CommitChanges();
                    View.ObjectSpace.Refresh();
                }
            }
        }
Beispiel #4
0
        public string saveregistdetail(string entityjson)
        {
            Dictionary <string, string> entity = JsonConvert.DeserializeObject <Dictionary <string, string> >(entityjson);

            RegisterDetail registentity = new RegisterDetail();

            registentity.role = entity.Where(x => x.Key == "role").First().Value;

            registentity.RowKey = entity.Where(x => x.Key == "userid").First().Value;

            if (registentity.role == roles.trainer.ToString())
            {
                registentity.PartitionKey = "TRAINER";
            }
            else
            {
                string trainerID = entity.Where(x => x.Key == "trainer").First().Value;


                registentity.PartitionKey = string.Format("TRAINEE-{0}", trainerID);

                registentity.macaddress = entity.Where(x => x.Key == "macaddress").First().Value;

                registentity.height = double.Parse(entity.Where(x => x.Key == "height").First().Value);

                registentity.weight = double.Parse(entity.Where(x => x.Key == "weight").First().Value);

                CultureInfo culture = CultureInfo.InvariantCulture;
                //registentity.startdate = Convert.ToDateTime(entity.Where(x => x.Key == "startdateLocal").First().Value,culture);
                try
                {
                    registentity.startdate = DateTime.ParseExact(entity.Where(x => x.Key == "startdateLocal").First().Value, "dd/MM/yyyy HH:mm:ss", culture).ToString();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
                registentity.startdateUTC = Convert.ToDateTime(entity.Where(x => x.Key == "startdateUTC").First().Value);

                registentity.isstartdate = true;
            }
            try
            {
                string result = registerdetail.InsertOrMerge(registentity);
                return(result);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(e.Message);
            }
        }
        public int SendEmail(RegisterDetail request)
        {
            var client = new SmtpClient(request.SmtpServerIP, request.SmtpServerPort)
            {
                Credentials           = new NetworkCredential(request.SmtpServerUsername, request.SmtpServerPassword),
                EnableSsl             = true,
                UseDefaultCredentials = false
            };

            client.Send(request.EmailObject.From, request.EmailObject.To, request.EmailObject.Subject, request.EmailObject.Body);

            return(1);
        }
Beispiel #6
0
 public ActionResult Register(RegisterDetail register)
 {
     if (ModelState.IsValid)
     {
         MailProcessor.ProcessOrder(register);
         OrderProcessor.Register(register);
         Session.Clear();
         return(RedirectToAction("Login"));
     }
     else
     {
         return(View());
     }
 }
        public RegisterDetail GetRegisterUserDetails(RegisterDetail request)
        {
            int            clientId, webRoleId, sequenceNo, webContactId;
            RegisterDetail response = new RegisterDetail();

            request.Suffix = "CM";
            _unitOfWork.GetRegisterUserDetails(request.InvitationCode, request.XRefId, request.Suffix, out clientId, out webRoleId, out sequenceNo, out webContactId);

            response.ClientId   = clientId;
            response.WebRoleId  = webRoleId.ToString();
            response.SequenceNo = sequenceNo;
            response.ContactId  = webContactId.ToString();
            return(response);
        }
        public ActionResult Register(RegisterDetail registerdetails)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //List<string> ids = registerdetails.R_Id.ToString();
                    //registerdetails.R_Id=

                    int id = db.RegisterDetails.Max(x => x.R_Id);
                    registerdetails.R_Id = id + 1;
                    db.RegisterDetails.Add(registerdetails);
                    ViewBag.registermsg = "Registered Successfully!";
                    db.SaveChanges();

                    var user = db.RegisterDetails.Single(u => u.R_Id == registerdetails.R_Id);
                    if (user.R_Role == "Customer")
                    {
                        CustomerDetail customerdetails = new CustomerDetail(user.R_Id, user.R_Username);
                        db.CustomerDetails.Add(customerdetails);
                        db.SaveChanges();
                        ViewBag.registermsg = "Registered Successfully!";
                    }
                    if (user.R_Role == "Admin")
                    {
                        AdminDetail Admindetails = new AdminDetail(user.R_Id, user.R_Username);
                        db.AdminDetails.Add(Admindetails);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewBag.message = e.Message;
                }
            }
            return(View());
        }
        void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e)
        {
            Dictionary <string, int> dicLessonCurrentRegNum = new Dictionary <string, int>();
            ObjectSpace         objectSpace = Application.CreateObjectSpace();
            ListView            lv          = ((ListView)((WindowController)sender).Window.View);
            User                u           = (User)SecuritySystem.CurrentUser;
            XPCollection <Role> xpc         = new XPCollection <Role>(u.Roles,
                                                                      new BinaryOperator("Name", "Administrators"));
            XPCollection <Role> xpc2 = new XPCollection <Role>(u.Roles,
                                                               new BinaryOperator("Name", "DataAdmins"));

            if (xpc.Count + xpc2.Count > 0)
            {
                objectSpace.Session.BeginTransaction();

                Student currentStudent;
                Lesson  curLesson;
                Dictionary <string, List <string> > errorstudent = new Dictionary <string, List <string> >();
                int numregok = 0;
                foreach (string studentCode in dicStudentRegDetail.Keys)
                {
                    currentStudent = objectSpace.FindObject <Student>(
                        new BinaryOperator("StudentCode", studentCode));
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        if (!dicLessonCurrentRegNum.ContainsKey(lesson.LessonName))
                        {
                            dicLessonCurrentRegNum[lesson.LessonName] = 0;
                        }
                        //si so chon chua vuot qua
                        if (lesson.NumExpectation > dicLessonCurrentRegNum[lesson.LessonName] + lesson.NumRegistration)
                        {
                            curLesson = objectSpace.FindObject <Lesson>(
                                new BinaryOperator("Oid", lesson.Oid));
                            RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                            {
                                Student       = currentStudent,
                                Lesson        = curLesson,
                                RegisterState = objectSpace.FindObject <RegisterState>(
                                    new BinaryOperator("Code", "SELECTED")),
                                CheckState = objectSpace.FindObject <RegisterState>(
                                    new BinaryOperator("Code", "NOTCHECKED"))
                            };
                            RuleSet ruleSet = new RuleSet();

                            RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                            if (ValidationState.Invalid ==
                                result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                            {
                                if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                {
                                    errorstudent.Add(currentStudent.StudentCode, new List <string>());
                                }
                                if (!errorstudent[currentStudent.StudentCode].Contains(curLesson.Subject.SubjectCode))
                                {
                                    errorstudent[currentStudent.StudentCode].Add(curLesson.Subject.SubjectCode);
                                }
                                regdetail.Delete();
                            }
                            else
                            {
                                numregok++;
                                dicLessonCurrentRegNum[lesson.LessonName]++;
                                regdetail.Save();
                            }
                        }
                        else
                        {
                            if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                            {
                                errorstudent.Add(currentStudent.StudentCode, new List <string>());
                            }
                            if (!errorstudent[currentStudent.StudentCode].Contains(lesson.Subject.SubjectCode))
                            {
                                errorstudent[currentStudent.StudentCode].Add(lesson.Subject.SubjectCode);
                            }
                        }
                    }
                }
                objectSpace.Session.CommitTransaction();
                PopUpMessage ms = objectSpace.CreateObject <PopUpMessage>();
                if (errorstudent.Count > 0)
                {
                    ms.Title   = "Có lỗi khi chọn nhóm MH đăng ký!";
                    ms.Message = string.Format("Đã chọn được cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                    string strmessage = "Không chọn được nhóm môn học do trùng môn đã đăng ký hoặc hết chỗ: ";
                    foreach (KeyValuePair <string, List <string> > keypair in errorstudent)
                    {
                        strmessage += string.Format("Sinh viên:[{0}] - Môn:[", keypair.Key);
                        foreach (string str in keypair.Value)
                        {
                            strmessage += str + ",";
                        }
                        strmessage  = strmessage.TrimEnd(',');
                        strmessage += "]\r\n";
                    }
                    ms.Message += strmessage;
                }
                else
                {
                    ms.Title   = "Chọn nhóm MH thành công";
                    ms.Message = string.Format("Chọn nhóm MH thành công cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                }
                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView = Application.CreateDetailView(
                    objectSpace, ms);
                svp.TargetWindow        = TargetWindow.NewModalWindow;
                svp.CreatedView.Caption = "Thông báo";
                DialogController dc = Application.CreateController <DialogController>();
                svp.Controllers.Add(dc);

                dc.SaveOnAccept = false;
                Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
            }
        }
Beispiel #10
0
        private void DefaultRegister_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();

            dicStudentRegDetail = new Dictionary <string, List <string> >();
            Student currentStudent;
            Lesson  curLesson;
            Dictionary <string, List <string> > errorstudent           = new Dictionary <string, List <string> >();
            Dictionary <string, int>            dicLessonCurrentRegNum = new Dictionary <string, int>();
            int     numregok = 0;
            Vacancy vc;
            bool    isConflictTKB = false;

            using (XPCollection <Lesson> newCollectionSource = new XPCollection <Lesson>(objectSpace.Session))
            {
                objectSpace.Session.BeginTransaction();
                foreach (StudentClass studentClass in View.SelectedObjects)
                {
                    newCollectionSource.Criteria = CriteriaOperator.Parse(
                        "ClassIDs like ?", string.Format("%{0}%", studentClass.ClassCode));

                    foreach (Student student in studentClass.Students)
                    {
                        listVacancies  = new List <Vacancy>();
                        currentStudent = objectSpace.FindObject <Student>(
                            new BinaryOperator("StudentCode", student.StudentCode));

                        foreach (Lesson lesson in newCollectionSource)
                        {
                            isConflictTKB = false;
                            if (!dicLessonCurrentRegNum.ContainsKey(lesson.LessonName))
                            {
                                dicLessonCurrentRegNum[lesson.LessonName] = 0;
                            }
                            foreach (TkbSemester tkbsem in lesson.TKBSemesters)
                            {
                                vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
                                if (Utils.IsConfictTKB(listVacancies, vc))
                                {
                                    isConflictTKB = true;
                                    break;
                                }
                            }

                            if (isConflictTKB)
                            {
                                if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                {
                                    errorstudent.Add(currentStudent.StudentCode, new List <string>());
                                }
                                if (!errorstudent[currentStudent.StudentCode].Contains(lesson.Subject.SubjectCode))
                                {
                                    errorstudent[currentStudent.StudentCode].Add(lesson.Subject.SubjectCode + "{T}");
                                }
                            }
                            else
                            {
                                //si so chon chua vuot qua
                                if (lesson.NumExpectation > dicLessonCurrentRegNum[lesson.LessonName] + lesson.NumRegistration)
                                {
                                    curLesson = objectSpace.FindObject <Lesson>(
                                        new BinaryOperator("Oid", lesson.Oid));
                                    RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                                    {
                                        Student       = currentStudent,
                                        Lesson        = curLesson,
                                        RegisterState = objectSpace.FindObject <RegisterState>(
                                            new BinaryOperator("Code", "SELECTED")),
                                        CheckState = objectSpace.FindObject <RegisterState>(
                                            new BinaryOperator("Code", "NOTCHECKED"))
                                    };
                                    RuleSet ruleSet = new RuleSet();

                                    RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                                    if (ValidationState.Invalid ==
                                        result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                                    {
                                        if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                        {
                                            errorstudent.Add(currentStudent.StudentCode, new List <string>());
                                        }
                                        if (!errorstudent[currentStudent.StudentCode].Contains(curLesson.Subject.SubjectCode))
                                        {
                                            errorstudent[currentStudent.StudentCode].Add(curLesson.Subject.SubjectCode + "{D}");
                                        }
                                        regdetail.Delete();
                                        //regdetail.Reload();
                                    }
                                    else
                                    {
                                        numregok++;
                                        if (!dicStudentRegDetail.ContainsKey(student.StudentCode))
                                        {
                                            dicStudentRegDetail.Add(student.StudentCode, new List <string>());
                                        }
                                        dicStudentRegDetail[student.StudentCode].Add(curLesson.LessonName);

                                        dicLessonCurrentRegNum[lesson.LessonName]++;
                                        foreach (TkbSemester tkbsem in curLesson.TKBSemesters)
                                        {
                                            vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
                                            listVacancies.Add(vc);
                                        }
                                        regdetail.Save();
                                    }
                                }
                                else
                                {
                                    if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                    {
                                        errorstudent.Add(currentStudent.StudentCode, new List <string>());
                                    }
                                    if (!errorstudent[currentStudent.StudentCode].Contains(lesson.Subject.SubjectCode))
                                    {
                                        errorstudent[currentStudent.StudentCode].Add(lesson.Subject.SubjectCode + "{H}");
                                    }
                                }
                            }
                        }
                    }
                }
                objectSpace.Session.CommitTransaction();
                PopUpMessage ms = objectSpace.CreateObject <PopUpMessage>();
                if (errorstudent.Count > 0)
                {
                    ms.Title   = "Có lỗi khi chọn nhóm MH đăng ký!";
                    ms.Message = string.Format("Đã chọn được cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                    string strmessage = "Không chọn được nhóm môn học do trùng môn đã đăng ký, trùng lịch hoặc hết chỗ: ";
                    foreach (KeyValuePair <string, List <string> > keypair in errorstudent)
                    {
                        strmessage += string.Format("Sinh viên:[{0}] - Môn:[", keypair.Key);
                        foreach (string str in keypair.Value)
                        {
                            strmessage += str + ",";
                        }
                        strmessage  = strmessage.TrimEnd(',');
                        strmessage += "]\r\n";
                    }
                    ms.Message += strmessage;
                }
                else
                {
                    ms.Title   = "Chọn nhóm MH thành công";
                    ms.Message = string.Format("Chọn nhóm MH thành công cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                }
                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView = Application.CreateDetailView(
                    objectSpace, ms);
                svp.TargetWindow        = TargetWindow.NewModalWindow;
                svp.CreatedView.Caption = "Thông báo";
                DialogController dc = Application.CreateController <DialogController>();
                svp.Controllers.Add(dc);

                dc.SaveOnAccept = false;
                Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
            }
        }
        public HttpResponseMessage RegisterUser([FromBody] RegisterDetail model)
        {
            string lError = "";

            try
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Model State is Invalid."));
                }

                //1. Get the ClientId and RoleId from SELECT @ClientId = ClientId, @WebRoleId = WebRoleId FROM ClientInvitationCodes WHERE InvitationCode = @invitationCode
                //2. Get the Max Sequence Number here
                RegisterDetail response = _registerServices.GetRegisterUserDetails(model);

                if (response.WebRoleId == "0" || response.ClientId == 0)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invitation Code is Invalid."));
                }

                if (UserManager.FindByName(model.Email) != null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Email Already Registered."));
                }

                //3. Call this method
                ApplicationUser user = new ApplicationUser()
                {
                    UserName       = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName,
                    FullName       = model.FirstName + " " + model.LastName, PhoneNumberConfirmed = false, IsNYAttorneyPortalUser = true,
                    Suffix         = model.Suffix, XRefId = response.ClientId, SequenceNo = response.SequenceNo, ContactType = "Registered",
                    LockoutEnabled = true, EmailConfirmed = false, CreatedBy = "System", CreatedDate = DateTime.Now, LastModDate = DateTime.Now, LastModBy = "System"
                };
                IdentityResult result = UserManager.Create(user);

                if (result.Succeeded)
                {
                    //4.Then call the webUserRolesUpdate
                    _registerServices.WebUserRolesUpdate(user.Id, int.Parse(response.WebRoleId));
                    string passswordResetUrl = ConfigurationManager.AppSettings["ForgotPasswordURL"];
                    response.PasswordResetUrl = passswordResetUrl + "?key=" + EncryptQueryStringParameter(user.Id + "|" + DateTime.Now);
                    model.EmailObject.Body    = model.EmailObject.Body.Replace(model.PasswordResetUrl, response.PasswordResetUrl);
                    //5.Insert the record in the EmailQueue table
                    int rowId = _registerServices.EmailQueueInsert(model.EmailObject.From, model.EmailObject.To, model.EmailObject.Subject, model.EmailObject.Body, "");
                    if (rowId < 0)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Email Sending Failed."));
                    }
                    response.ResponseMessage = "";
                }
                else
                {
                    foreach (string error in result.Errors)
                    {
                        lError = lError + error + "\r\n";
                    }
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, lError));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Beispiel #12
0
        void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();

            DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
            User u = (User)SecuritySystem.CurrentUser;
            XPCollection <Role> xpc = new XPCollection <Role>(u.Roles,
                                                              new BinaryOperator("Name", "Administrators"));
            XPCollection <Role> xpc2 = new XPCollection <Role>(u.Roles,
                                                               new BinaryOperator("Name", "DataAdmins"));

            if (xpc.Count + xpc2.Count > 0)
            {
                objectSpace.Session.BeginTransaction();

                Student currentStudent;
                Lesson  curLesson;
                foreach (string studentCode in listStudentCode)
                {
                    currentStudent = objectSpace.FindObject <Student>(
                        new BinaryOperator("StudentCode", studentCode));
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        curLesson = objectSpace.FindObject <Lesson>(
                            new BinaryOperator("Oid", lesson.Oid));
                        RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                        {
                            Student       = currentStudent,
                            Lesson        = curLesson,
                            RegisterState = objectSpace.FindObject <RegisterState>(
                                new BinaryOperator("Code", "SELECTED")),
                            CheckState = objectSpace.FindObject <RegisterState>(
                                new BinaryOperator("Code", "NOTCHECKED"))
                        };
                        RuleSet ruleSet = new RuleSet();

                        RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                        if (ValidationState.Invalid ==
                            result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                        {
                            regdetail.Delete();
                        }
                        else
                        {
                            regdetail.Save();
                        }
                    }
                }
                objectSpace.Session.CommitTransaction();

                PopUpMessage ms = objectSpace.CreateObject <PopUpMessage>();
                ms.Title   = "Lỗi đăng ký";
                ms.Message = string.Format("Error");
                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView = Application.CreateDetailView(
                    objectSpace, ms);
                svp.TargetWindow        = TargetWindow.NewModalWindow;
                svp.CreatedView.Caption = "Thông báo";
                DialogController dc = Application.CreateController <DialogController>();
                svp.Controllers.Add(dc);

                dc.SaveOnAccept = false;
                Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
                ////               View.ObjectSpace.CommitChanges();
                //View.ObjectSpace.Refresh();
                //ListView view = null;
                //Frame currentFrame = ((ActionBase)sender).Controller.Frame;
                //switch (currentFrame.View.ObjectTypeInfo.Name)
                //{
                //    case "Student":
                //        view = Application.CreateListView(objectSpace,typeof(RegisterDetail),true);
                //        break;
                //}
                //currentFrame.SetView(view);
                //e.Cancel = true;
            }
        }