示例#1
0
        [HttpPost] //Skickar värderna som användaren skriver in
        public async Task <ActionResult> RegistrationUser(ProfilesClass registration)
        {
            registration.Profile_Role = "Besökare"; // Besökare blir standardroll för alla som registrerar sig

            using (var client = new HttpClient())
            {
                RegistrationClass Registration = new RegistrationClass {
                    Email = registration.Profile_Email, Firstname = registration.Profile_Firstname, Lastname = registration.Profile_Lastname, Password = registration.Profile_Password, Role = registration.Profile_Role
                };

                client.BaseAddress = new Uri("http://193.10.202.76/api/");

                HttpResponseMessage postTask = await client.PostAsJsonAsync("visitor", Registration);

                if (postTask.IsSuccessStatusCode)
                {
                    var result = postTask.Content.ReadAsStringAsync().Result;

                    registration.Profile_User_Id = Int32.Parse(result.ToString());

                    ProfilesClass b = new ProfilesClass {
                        Profile_Email = registration.Profile_Email, Profile_Firstname = registration.Profile_Firstname, Profile_Lastname = registration.Profile_Lastname, Profile_PhoneNr = registration.Profile_PhoneNr, Profile_Birthday = registration.Profile_Birthday, Profile_Role = registration.Profile_Role, Profile_User_Id = registration.Profile_User_Id
                    };
                    SaveProfile(b);
                    return(RedirectToAction("LoginUser", "Login"));
                }

                return(View(registration));
            }
        }
        public static string PopulateBodyChooseTutor(Tutor tutor, Customer customer, RegistrationClass registrationClass, string templateUrl)
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath(templateUrl)))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("[TutorFullName]", tutor.FullName);
            body = body.Replace("[CustomerFullName]", customer.FullName);
            body = body.Replace("[ClassCode]", registrationClass.Id.ToString());
            body = body.Replace("[GradeName]", tutor.Id.ToString());
            string SubjectNames = "";

            foreach (var item in registrationClass.Subjects)
            {
                SubjectNames += " - " + item.Name;
            }
            body = body.Replace("[SubjectNames]", SubjectNames);
            body = body.Replace("[SalaryPerMonth]", registrationClass.SalaryPerMonth);
            body = body.Replace("[TutoringTime]", registrationClass.TutoringTime);
            body = body.Replace("[DayPerWeek]", registrationClass.DayPerWeek.ToString());
            body = body.Replace("[Street]", registrationClass.Street);
            body = body.Replace("[Ward]", registrationClass.Ward);
            body = body.Replace("[District]", registrationClass.District);
            body = body.Replace("[City]", registrationClass.City);
            return(body);

            return(body);
        }
示例#3
0
        public ActionResult CreateAccount(RegistrationClass registrationClass)
        {
            HttpClient          httpClient = new HttpClient();
            HttpContent         httpContent;
            HttpResponseMessage response = new HttpResponseMessage();

            string data = "{'Name':'" + registrationClass.Name + "'" +
                          ",'Email':'" + registrationClass.Email + "'" +
                          ",'Password':'******'}";

            httpContent = new StringContent(data, Encoding.UTF8, "application/json");


            response = httpClient.PostAsync("http://localhost:55700/API/APITest/save", httpContent).Result;
            var resultData = response.Content.ReadAsStringAsync().Result;

            //var json = JObject.Parse(resultData);

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                ViewBag.erroseMessage = "This user already exist in the system!";
            }
            return(View());
        }
示例#4
0
        public HttpStatusCodeResult ReceiveClass(int ClassId)
        {
            try
            {
                string            tutorUsername     = User.Identity.GetUserName();
                string            UserId            = User.Identity.GetUserId();
                RegistrationClass RegistrationClass = db.RegistrationClasses.Include(s => s.Customer).SingleOrDefault(s => s.Id == ClassId);
                Customer          customer          = RegistrationClass.Customer;
                string            customerUsername  = UserManager.FindById(customer.UserId).UserName;
                Tutor             tutor             = db.Tutors.SingleOrDefault(s => s.UserId == UserId);
                RegistrationClass.Tutor  = tutor;
                RegistrationClass.Status = Enums.ClassStatus.WaitingForCustomerApproval;

                db.Entry(RegistrationClass).State = EntityState.Modified;
                db.SaveChanges();
                //send to tutor
                EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Yêu cầu nhận lớp mã số : " + RegistrationClass.Id,
                                                          EmailSenderService.PopulateBody(customer.FullName, tutor.FullName, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToTutor.html"));
                //send to customer
                EmailSenderService.SendHtmlFormattedEmail(customer.Email, "Yêu cầu nhận lớp",
                                                          EmailSenderService.PopulateBodyTutorEnrollClassNotificationToCustomer(customer.FullName, tutor, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToCustomer.html"));
                //send to admin
                EmailSenderService.SendHtmlFormattedEmail(AdminEmail, "Gia sư đăng kí nhận lớp",
                                                          EmailSenderService.PopulateBodyTutorEnrollClassNotificationToAdmin(customer, customerUsername, tutor, tutorUsername, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToAdmin.html"));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
示例#5
0
 private void btnOK_Click(object sender, System.EventArgs e)
 {
     try
     {
         string serial = this.txtSerial1.Text + this.txtSerial2.Text + this.txtSerial3.Text +
                         this.txtSerial4.Text + this.txtSerial5.Text;
         if (serial == RegistrationClass.GetEncryptedKeyFull())
         {
             int roomsCount = RegistrationClass.GetRoomsCount();
             RegistrationClass.StoreKeyToRegistry(serial);
             RegistrationClass.StoreKeyToRegistry("Vlera2", roomsCount.ToString().Length.ToString());
             MessageBox.Show("Rregjistrimi i programit u krye me sukses per " + roomsCount + " dhoma" +
                             Environment.NewLine + "Ju lutemi hapni dhe mbyllni programin perseri qe ndryshimet te "
                             + "te pasqyrohen ne program.", "Rregjistrimi", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("Numri serial qe ju futet nuk eshte i sakte. Ju lutemi provoni perseri ose merrni numrin serial nga VisionInfoSolution", "Rregjistrimi", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }
        private void Submit_Click(object sender, EventArgs e)
        {
            User newUser = new User()
            {
                Name     = this.userName.Text,
                Address  = this.userAddress.Text,
                Email    = this.email.Text,
                Password = this.password.Text,
                Gender   = this.gender.Text,
                Status   = this.status.Text
            };
            RegistrationClass rcs = new RegistrationClass();

            if (rcs.Validation(newUser, this.cPassword.Text))
            {
                bool x = rcs.RegisterUser(newUser);
                if (x)
                {
                    MessageBox.Show("Registration Succesful", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBox.Show("Registration Failed");
                }
            }
            else
            {
                MessageBox.Show("Please Fill up all the field", "Oops!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#7
0
        private void SelectPhoto(object sender, RoutedEventArgs e)
        {
            string imgBT = RegistrationClass.FileLoader();

            photoBox.Text = imgBT;
            Bitmap      BT  = new Bitmap(imgBT);
            BitmapImage nBT = RegistrationClass.ConvertToImage(BT);

            photoImage.Source = nBT;
        }
示例#8
0
        private void SelectPhoto(object sender, RoutedEventArgs e)
        {
            string filename = RegistrationClass.FileLoader();

            tbFilename.Text = filename;
            Bitmap      BT   = new Bitmap(filename);
            BitmapImage imBT = RegistrationClass.ConvertToImage(BT);

            logo.Source = imBT;
        }
示例#9
0
        public ActionResult EditAccount(long id)
        {
            RegistrationClass   registrationClass = new RegistrationClass();
            HttpClient          httpClient        = new HttpClient();
            HttpContent         httpContent;
            HttpResponseMessage response = new HttpResponseMessage();

            var Email    = System.Web.HttpContext.Current.Session["Email"];
            var Password = System.Web.HttpContext.Current.Session["Password"];


            using (var client = new HttpClient())
            {
                string tokenData = "{'Email':'" + Email + "'" +
                                   ",'Password':'******'}";

                httpContent = new StringContent(tokenData, Encoding.UTF8, "application/json");

                response = client.PostAsync("http://localhost:55700/API/APITest/GetToken", httpContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    response = httpClient.GetAsync("http://localhost:55700/API/APITest/GetUser?userId=" + id).Result;


                    if (Convert.ToInt32(response.StatusCode) != 401)
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            var mess = response.Content.ReadAsStringAsync().Result;

                            var json = JObject.Parse(mess);

                            registrationClass.UserId   = Convert.ToInt64(json["UserId"].ToString());
                            registrationClass.Name     = json["Name"].ToString();
                            registrationClass.Email    = json["Email"].ToString();
                            registrationClass.Password = json["Password"].ToString();
                        }
                        else
                        {
                            ViewBag.erroseMessage = "No Data found";
                        }
                        return(View(registrationClass));
                    }
                    else
                    {
                        return(RedirectToAction("Login"));
                    }
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
        }
示例#10
0
        private void Registration(object sender, RoutedEventArgs e)
        {
            Gender  gender  = (Gender)genderBox.SelectedItem;
            Country country = (Country)countryBox.SelectedItem;

            string image = photoBox.Text;

            byte[] byteImg = RegistrationClass.ConvertToByte(image);

            User user = new User
            {
                Email     = emailBox.Text,
                Password  = passBox.Text,
                FirstName = firstNameBox.Text,
                LastName  = secondNameBox.Text,
                RoleId    = "R"
            };

            Runner runner = new Runner
            {
                Email       = emailBox.Text,
                Gender      = gender.GenderRow,
                DateOfBirth = datePicker.SelectedDate,
            };

            if (byteImg != null)
            {
                runner.Photo = byteImg;
            }

            foreach (Country c in db.Country)
            {
                if (c.CountryName == country.CountryName)
                {
                    runner.CountryCode = c.CountryCode;
                    break;
                }
            }

            if ((RegistrationClass.PasswordCheck(passBox.Text, passConfirm.Text)) && (RegistrationClass.EmailCheck(emailBox.Text)) && RegistrationClass.AgeCheck(datePicker))
            {
                db.User.Add(user);
                db.Runner.Add(runner);
                db.SaveChanges();

                MessageBox.Show("Регистрация успешно завершена!");

                CurrentUser.RunnerId = runner.RunnerId;
                CurrentUser.Email    = emailBox.Text;

                Manager.MainFrame.Navigate(new RegisterAnEvent());
                ;
            }
        }
示例#11
0
        public ActionResult EditAccount(RegistrationClass registrationClass)
        {
            HttpClient          httpClient = new HttpClient();
            HttpContent         httpContent;
            HttpResponseMessage response = new HttpResponseMessage();
            var Email    = System.Web.HttpContext.Current.Session["Email"];
            var Password = System.Web.HttpContext.Current.Session["Password"];

            using (var client = new HttpClient())
            {
                string tokenData = "{'Email':'" + Email + "'" +
                                   ",'Password':'******'}";

                httpContent = new StringContent(tokenData, Encoding.UTF8, "application/json");

                response = client.PostAsync("http://localhost:55700/API/APITest/GetToken", httpContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    string data = "{'UserId':'" + registrationClass.UserId + "'" +
                                  ",'Name':'" + registrationClass.Name + "'" +
                                  ",'Email':'" + registrationClass.Email + "'" +
                                  ",'Password':'******'}";

                    httpContent = new StringContent(data, Encoding.UTF8, "application/json");


                    response = httpClient.PutAsync("http://localhost:55700/API/APITest/Update", httpContent).Result;
                    var resultData = response.Content.ReadAsStringAsync().Result;

                    if (Convert.ToInt32(response.StatusCode) != 401)
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ViewBag.erroseMessage = "Data didn't updated!";
                        }
                        return(View());
                    }
                    else
                    {
                        return(RedirectToAction("Login"));
                    }
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
        }
示例#12
0
        // GET: ManageRegistrationClasses/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RegistrationClass registrationClass = await db.RegistrationClasses.FindAsync(id);

            if (registrationClass == null)
            {
                return(HttpNotFound());
            }
            return(View(registrationClass));
        }
示例#13
0
        public ActionResult Delete(long id)
        {
            RegistrationClass   registrationClass = new RegistrationClass();
            HttpClient          httpClient        = new HttpClient();
            HttpContent         httpContent;
            HttpResponseMessage response = new HttpResponseMessage();

            var Email    = System.Web.HttpContext.Current.Session["Email"];
            var Password = System.Web.HttpContext.Current.Session["Password"];

            //string data = "{'userId':'" + id + "' }";
            //httpContent = new StringContent(data, Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                string tokenData = "{'Email':'" + Email + "'" +
                                   ",'Password':'******'}";

                httpContent = new StringContent(tokenData, Encoding.UTF8, "application/json");

                response = client.PostAsync("http://localhost:55700/API/APITest/GetToken", httpContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    response = httpClient.DeleteAsync("http://localhost:55700/API/APITest/Delete?userId=" + id).Result;

                    if (Convert.ToInt32(response.StatusCode) != 401)
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ViewBag.erroseMessage = "Data didn't deleted";
                        }
                        return(View());
                    }
                    else
                    {
                        return(RedirectToAction("Login"));
                    }
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
        }
示例#14
0
        public ActionResult DeleteClassRegistration(int id)
        {
            RegistrationClass Class = db.RegistrationClasses.SingleOrDefault(s => s.Id == id);

            if (Class != null)
            {
                Class.Grade    = null;
                Class.Subjects = null;
                Class.Tutor    = null;
                Class.Customer = null;

                db.RegistrationClasses.Remove(Class);
                db.SaveChanges();
            }

            return(RedirectToAction("ClassManagementView", "Admin"));
        }
示例#15
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string serial = this.txtSerial1.Text + this.txtSerial2.Text + this.txtSerial3.Text + this.txtSerial4.Text;

            if (serial == RegistrationClass.GetEncryptedKeyFull())
            {
                RegistrationClass.StoreKeyToRegistry(serial);
                MessageBox.Show("Rregjistrimi i programit u krye me sukses", "Rregjistrimi i programit", MessageBoxButtons.OK, MessageBoxIcon.Information);
                regSakte = true;
            }
            else
            {
                MessageBox.Show("Numri qe vendoset nuk eshte i sakte. Ju lutemi kontaktoni me VisionInfoSolution!", "Rregjistrimi i programit", MessageBoxButtons.OK, MessageBoxIcon.Error);
                regSakte = false;
            }
            this.Close();
        }
示例#16
0
        private void SaveChanges(object sender, RoutedEventArgs e)
        {
            var charity = db.Charity
                          .Where(c => c.CharityName == currentCharity.CharityName)
                          .FirstOrDefault();

            string filename = tbFilename.Text;

            if (charity == null) //проверка для выбора редактирования или создания спонсора
            {                    //если такой нет, то создаем
                filename = tbFilename.Text;
                byte[] image = null;
                if (filename != "")
                {
                    image = RegistrationClass.ConvertToByte(filename);
                }

                Charity AddCharity = new Charity
                {
                    CharityName        = tbName.Text,
                    CharityDescription = tbDescription.Text,
                    CharityLogo        = image,
                };

                db.Charity.Add(AddCharity);
                db.SaveChanges();
            }
            else //иначе редачим текущую
            {
                charity.CharityName        = tbName.Text;
                charity.CharityDescription = tbDescription.Text;

                filename = tbFilename.Text;

                if (filename != "")
                {
                    byte[] image = RegistrationClass.ConvertToByte(filename);
                    charity.CharityLogo = image;
                }

                db.SaveChanges();
            }
        }
示例#17
0
        public HttpStatusCodeResult ApproveOrRejectEnrollClass(int ClassId, bool IsApproved)
        {
            try
            {
                string            customerUsername  = User.Identity.GetUserName();
                RegistrationClass RegistrationClass = db.RegistrationClasses.Include(s => s.Customer).Include(s => s.Tutor).Include(s => s.Subjects).SingleOrDefault(s => s.Id == ClassId);
                Tutor             tutor             = RegistrationClass.Tutor;
                string            tutorUsername     = UserManager.FindById(tutor.UserId).UserName;
                Customer          customer          = RegistrationClass.Customer;
                if (IsApproved)
                {
                    RegistrationClass.Tutor           = tutor;
                    RegistrationClass.Status          = Enums.ClassStatus.CustomerApproved;
                    RegistrationClass.ReceivedDate    = DateTime.Now;
                    RegistrationClass.IsClosed        = true;
                    db.Entry(RegistrationClass).State = EntityState.Modified;
                    db.SaveChanges();
                    //send to tutor
                    EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Đã duyệt yêu cầu nhận lớp" + RegistrationClass.Id,
                                                              EmailSenderService.PopulateBodyTutorCustomerApprovedEnrollmentRequestToTutor(customer, tutor, RegistrationClass, "~/EmailTemplates/CustomerApprovedTutorEnrollmenToTutor.html"));

                    //send to admin
                    EmailSenderService.SendHtmlFormattedEmail(AdminEmail, "Yêu cầu gia sư nhận lớp được duyệt",
                                                              EmailSenderService.PopulateBodyTutorCustomerApprovedEnrollmentRequestToAdmin(customer, customerUsername, tutor, tutorUsername, RegistrationClass.Id.ToString(), "~/EmailTemplates/CustomerApprovedTutorEnrollmentToAdmin.html"));
                }
                else
                {
                    RegistrationClass.Status          = Enums.ClassStatus.CustomerRejected;
                    db.Entry(RegistrationClass).State = EntityState.Modified;
                    db.SaveChanges();
                    //send to tutor
                    EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Từ chối yêu cầu nhận lớp mã số : " + RegistrationClass.Id,
                                                              EmailSenderService.PopulateBody(customer.FullName, tutor.FullName, RegistrationClass.Id.ToString(), "~/EmailTemplates/CustomerRejectedTutorEnrollmentToTutor.html"));
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
示例#18
0
        public ActionResult LoginUser(RegistrationClass inlogg)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:19779/api/Login");

                //HTTP POST
                var postTask = client.PostAsJsonAsync("Login", inlogg);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    // Anropa API för att påbörja Sessionen
                    return(RedirectToAction("Index", "Home"));
                }
                ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");

                return(View(inlogg));
            }
        }
示例#19
0
        [HttpPost] //Skickar värderna som användaren skriver in
        public ActionResult RegistrationUser(RegistrationClass registration)
        {
            registration.Registration_Role = "Besökare"; // Besökare blir standardroll för alla som registrerar sig
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://193.10.202.76/api/visitor");

                //HTTP POST
                var postTask = client.PostAsJsonAsync("/PostVisitor", registration); // Kolla med grupp1 att det är rätt metod
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("LoginUser", "Login"));
                }
                ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");

                return(View(registration));
            }
        }
示例#20
0
 private void btnOK_Click(object sender, System.EventArgs e)
 {
     if (this.numNrDhomash.Text == "")
     {
         this.error1.SetError(this.numNrDhomash, "Fusha e numrit te dhomave nuk mund te lihet bosh");
         return;
     }
     if (!Regex.IsMatch(this.numNrDhomash.Text, "^-?[0-9]*(\\,)?[0-9]+$"))
     {
         this.error1.SetError(this.numNrDhomash, "Vlera duhet te jete numer");
         return;
     }
     if (Convert.ToInt32(this.numNrDhomash.Text) < 0)
     {
         this.error1.SetError(this.numNrDhomash, "Vlera duhet te jete me e madhe se zero");
         return;
     }
     this.error1.SetError(this.numNrDhomash, "");
     if (!this.firstTimeOpen)
     {
         if (this.numNrDhomash.Text == this.initialValue.ToString())
         {
             // Ne kete rast nuk bejme modifikim sepse numrat jane te njejte
             this.Close();
             return;
         }
         RegistrationClass.EditRegistryKey(this.initialValue, Convert.ToInt32(this.numNrDhomash.Text));
         MessageBox.Show("Numri i dhomave qe mban hoteli u ndryshua." + Environment.NewLine +
                         "Per cdo problem kontaktoni me VisionInfoSolution", "Ndryshimi i dhomave",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
         return;
     }
     RegistrationClass.StoreKeyToRegistry(Convert.ToInt32(this.numNrDhomash.Text));
     MessageBox.Show("Numri i dhomave qe mban hoteli u ruajt", "Ndryshimi i dhomave",
                     MessageBoxButtons.OK, MessageBoxIcon.Information);
     this.Close();
 }
示例#21
0
        public JsonResult ApproveOrRejectClass(int ClassId, bool IsApproved)
        {
            try
            {
                RegistrationClass Class    = db.RegistrationClasses.Include(s => s.Customer).SingleOrDefault(s => s.Id == ClassId);
                Customer          customer = Class.Customer;
                if (IsApproved)
                {
                    Class.Status = Enums.ClassStatus.AdminApproved;
                    if (Class.Customer != null)
                    {
                        EmailSenderService.SendHtmlFormattedEmail(Class.Customer.Email, "Lớp đã được duyệt",
                                                                  EmailSenderService.PopulateBodyApprovedOrRejectedClass(Class.Customer.FullName, ClassId.ToString(), "~/EmailTemplates/ClassRegistrationApprovedNotification.html"));
                    }
                }

                else
                {
                    Class.Status = Enums.ClassStatus.AdminReject;
                    if (Class.Customer != null)
                    {
                        EmailSenderService.SendHtmlFormattedEmail(Class.Customer.Email, "Lớp bị từ chối",
                                                                  EmailSenderService.PopulateBodyApprovedOrRejectedClass(Class.Customer.FullName, ClassId.ToString(), "~/EmailTemplates/ClassRegistrationRejectedNotification.html"));
                    }
                }

                db.Entry(Class).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Json(new { Status = "Error" }));
            }

            return(Json(new { Status = "OK" }));
        }
示例#22
0
        private void SaveChanges(object sender, RoutedEventArgs e)
        {
            Gender  gender  = (Gender)genderBox.SelectedItem;
            Country country = (Country)countryBox.SelectedItem;

            string filename;

            byte[] imageToDb = { 0 };

            if (photoBox.Text != "")
            {
                filename  = photoBox.Text;
                imageToDb = RegistrationClass.ConvertToByte(filename);
            }

            var runner = db.Runner
                         .Where(r => r.Email == CurrentUser.Email)
                         .FirstOrDefault();
            var user = db.User
                       .Where(u => u.Email == CurrentUser.Email)
                       .FirstOrDefault();

            if (runner == null) //проверка на наличие бегуна в таблице, если нет, то создается новый бегун с присвоением нынешнего email
            {
                Runner r = new Runner();
                r.Email        = CurrentUser.Email;
                user.FirstName = firstNameBox.Text;
                user.LastName  = secondNameBox.Text;
                r.DateOfBirth  = datePicker.SelectedDate;
                r.Gender       = gender.GenderRow;
                r.Photo        = imageToDb;

                foreach (Country c in db.Country)
                {
                    if (c.CountryName == country.CountryName)
                    {
                        r.CountryCode = c.CountryCode;
                        break;
                    }
                }

                db.Runner.Add(r);
                db.SaveChanges();
            }
            else //иначе редактируется имеющийся бегун
            {
                user.FirstName     = firstNameBox.Text;
                user.LastName      = secondNameBox.Text;
                runner.DateOfBirth = datePicker.SelectedDate;
                runner.Gender      = gender.GenderRow;
                runner.Photo       = imageToDb;

                foreach (Country c in db.Country)
                {
                    if (c.CountryName == country.CountryName)
                    {
                        runner.CountryCode = c.CountryCode;
                        break;
                    }
                }
            }

            if (RegistrationClass.AgeCheck(datePicker))
            {
                db.SaveChanges();
                Manager.MainFrame.Navigate(new RunnerMenu());
            }
        }
示例#23
0
        public ActionResult Index()
        {
            var Email    = System.Web.HttpContext.Current.Session["Email"];
            var Password = System.Web.HttpContext.Current.Session["Password"];
            IList <RegistrationClass> userList     = new List <RegistrationClass>();
            List <RegistrationClass>  userListData = new List <RegistrationClass>();

            HttpClient          httpClient = new HttpClient();
            HttpContent         httpContent;
            HttpResponseMessage response = new HttpResponseMessage();

            using (var client = new HttpClient())
            {
                string tokenData = "{'Email':'" + Email + "'" +
                                   ",'Password':'******'}";

                httpContent = new StringContent(tokenData, Encoding.UTF8, "application/json");


                //response = httpClient.PostAsync("http://localhost:55700/API/APITest/save", httpContent).Result;
                response = client.PostAsync("http://localhost:55700/API/APITest/GetToken", httpContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    response = httpClient.GetAsync("http://localhost:55700/API/APITest/GetList").Result;


                    if (response.IsSuccessStatusCode)
                    {
                        var resultData = response.Content.ReadAsStringAsync().Result;
                        var arrayList  = JArray.Parse(resultData);

                        foreach (var item in arrayList)
                        {
                            userList.Add(item.ToObject <RegistrationClass>());
                        }
                    }
                    else
                    {
                        ViewBag.erroseMessage = "No Data found";
                    }

                    foreach (var item in userList)
                    {
                        RegistrationClass registrationClass = new RegistrationClass();
                        registrationClass.UserId   = item.UserId;
                        registrationClass.Name     = item.Name;
                        registrationClass.Email    = item.Email;
                        registrationClass.Password = item.Password;
                        userListData.Add(registrationClass);
                    }

                    ViewModel data = new ViewModel();
                    data.UserAccountList = userListData;
                    return(View(data));
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
        }
示例#24
0
        public ActionResult CreateAccount()
        {
            RegistrationClass registrationClass = new RegistrationClass();

            return(View(registrationClass));
        }
示例#25
0
 private void NumriSerial_Load(object sender, EventArgs e)
 {
     this.txtNrPerRregjistrim.Text = RegistrationClass.GetKey();
 }
示例#26
0
 private void NumriSerial_Load(object sender, System.EventArgs e)
 {
     this.txtNumerSerial.Text = RegistrationClass.GetKey();
 }
示例#27
0
 private void NumriDhomave_Load(object sender, System.EventArgs e)
 {
     this.initialValue      = RegistrationClass.GetRoomsCount();
     this.numNrDhomash.Text = this.initialValue.ToString();
     // TODO: Merr numrin e dhomave nga regjistri dhe hidhe ne numericBox dhe ne initialValue
 }