Beispiel #1
0
        private async void SaveConsultation(object consultationObject)
        {
            Consultation consultation = consultationObject as Consultation;

            if (consultation != null)
            {
                IsBusy = true;
                // редактирование
                if (consultation.Id > 0)
                {
                    Consultation updatedConsultation = await consultationsService.Update(consultation);

                    // заменяем объект в списке на новый
                    if (updatedConsultation != null)
                    {
                        int pos = Consultations.IndexOf(updatedConsultation);
                        Consultations.RemoveAt(pos);
                        Consultations.Insert(pos, updatedConsultation);
                    }
                }
                // добавление
                else
                {
                    Consultation addedConsultation = await consultationsService.Add(consultation);

                    if (addedConsultation != null)
                    {
                        Consultations.Add(addedConsultation);
                    }
                }
                IsBusy = false;
            }
            Back();
        }
Beispiel #2
0
 public ConsultationPage(Consultation model, ConsultationViewModel viewModel)
 {
     InitializeComponent();
     Model               = model;
     ViewModel           = viewModel;
     this.BindingContext = this;
 }
        // обновляем друга
        public async Task <Consultation> Update(Consultation consultation)
        {
            HttpClient client   = GetClient();
            var        response = await client.PutAsync(Url + "/" + consultation.Id,
                                                        new StringContent(
                                                            JsonConvert.SerializeObject(consultation),
                                                            Encoding.UTF8, "application/json"));

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <Consultation>(
                       await response.Content.ReadAsStringAsync()));
        }
Beispiel #4
0
        private async void DeleteConsultation(object consultationObject)
        {
            Consultation consultation = consultationObject as Consultation;

            if (consultation != null)
            {
                IsBusy = true;
                Consultation deletedConsultation = await consultationsService.Delete(consultation.Id);

                if (deletedConsultation != null)
                {
                    Consultations.Remove(deletedConsultation);
                }
                IsBusy = false;
            }
            Back();
        }
        public override bool Equals(object obj)
        {
            Consultation consultation = obj as Consultation;

            return(this.Id == consultation.Id);
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            var db          = new ApplicationDbContext();
            var userStore   = new UserStore <ApplicationUser>(db);
            var userManager = new UserManager <ApplicationUser>(userStore);


            var roleStore   = new RoleStore <IdentityRole>(db);
            var roleManager = new RoleManager <IdentityRole>(roleStore);

            //If db is empty
            if (!db.Consultations.Any())
            {
                //Create new consultation data
                var cone = new Consultation {
                    Teacher = "Kristjan Kivikangur", Subject = "Võrgurakendused", Difficulty = Difficulties.Test, Title = "Wordpress", Time = DateTime.Now, Day = Days.Friday
                };
                var ctwo = new Consultation {
                    Teacher = "Margit Uiboaid", Subject = "Inglise keel", Difficulty = Difficulties.PopQuiz, Title = "Grammar", Time = DateTime.Now, Day = Days.Monday
                };
                var cthree = new Consultation {
                    Teacher = "Karel Vendla", Subject = "Elu", Difficulty = Difficulties.Exam, Title = "Suvi", Time = DateTime.Now, Day = Days.Thursday
                };
                var cfour = new Consultation {
                    Teacher = "Silva Kiveste", Subject = "Ajalugu", Difficulty = Difficulties.Test, Title = "Teine maailmasõda", Time = DateTime.Now, Day = Days.Tuesday
                };
                var cfive = new Consultation {
                    Teacher = "Lembit Edu", Subject = "Multimeedia", Difficulty = Difficulties.PopQuiz, Title = "Blender ", Time = DateTime.Now, Day = Days.Wednesday
                };
                var csix = new Consultation {
                    Teacher = "Kristjan Kivikangur", Subject = "Agiilsed tarkvaraarenduse metoodikad", Difficulty = Difficulties.Test, Title = "Taesemetöö", Time = DateTime.Now, Day = Days.Monday
                };
                var cseven = new Consultation {
                    Teacher = "Lury Shkarbanova", Subject = "Andmebaaside alused", Difficulty = Difficulties.Test, Title = "Aviafirma db", Time = DateTime.Now, Day = Days.Thursday
                };
                var ceight = new Consultation {
                    Teacher = "Helen Nagel", Subject = "Mobiilirakendused", Difficulty = Difficulties.Test, Title = "TicTacToe", Time = DateTime.Now, Day = Days.Friday
                };
                var cnine = new Consultation {
                    Teacher = "Irina Peetrim'gi", Subject = "Vene keel", Difficulty = Difficulties.Test, Title = "Kokkuvõtlik töö", Time = DateTime.Now, Day = Days.Tuesday
                };
                var cten = new Consultation {
                    Teacher = "Tatjana Smagol", Subject = "Eesti keel", Difficulty = Difficulties.Test, Title = "Kirjavahemärgid", Time = DateTime.Now, Day = Days.Wednesday
                };


                db.Consultations.Add(cone);
                db.Consultations.Add(ctwo);
                db.Consultations.Add(cthree);
                db.Consultations.Add(cfour);
                db.Consultations.Add(cfive);
                db.Consultations.Add(csix);
                db.Consultations.Add(cseven);
                db.Consultations.Add(ceight);
                db.Consultations.Add(cnine);
                db.Consultations.Add(cten);
            }


            //Find user SuperAdmin
            var SuperUserExists = db.Users.Any(u => u.UserName == "SuperAdmin");

            //Create superadmin data
            var user = new ApplicationUser()
            {
                UserName = "******", Email = "*****@*****.**"
            };

            //If SuperUser not found in db
            if (!SuperUserExists)
            {
                //Submit data to database
                userManager.Create(user, "SuperAdmin123!");
            }

            //Find role admin
            var AdminRoleExists = db.Roles.Any(r => r.Name == "Admin");

            //If Role admin doesn't exist
            if (!AdminRoleExists)
            {
                //Create role Admin
                roleManager.Create(new IdentityRole("Admin"));
                roleManager.Create(new IdentityRole("Teacher"));

                //Add Role to database
                userManager.AddToRole(user.Id, "Admin");
            }
            //Save changes to database
            db.SaveChanges();



            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }