Exemplo n.º 1
0
        private async Task RegisterUserAsync(string route)
        {
            if (SelectedLocation == null)
            {
                MessagingCenter.Send <Application, DisplayAlertMessage>(Application.Current, "ShowAlert",
                                                                        new DisplayAlertMessage {
                    Title = "Warning", Message = "Place of residence must be selected!", Cancel = "OK"
                });
                return;
            }

            if (!ValidateForm())
            {
                return;
            }

            try
            {
                IsBusy = true;
                Narucioci narucilac = new Narucioci
                {
                    Ime            = Firstname.Value,
                    Prezime        = Lastname.Value,
                    Username       = Username.Value,
                    BlokId         = SelectedLocation.BlokID,
                    DatumKreiranja = DateTime.Now,
                    BadgeId        = 1
                };

                narucilac.LozinkaSalt = UIHelper.GenerateSalt();
                narucilac.LozinkaHash = UIHelper.GenerateHash(narucilac.LozinkaSalt, Password.Value);

                await BaseClient.Client.RegisterAsync(narucilac);

                IsBusy = false;

                MessagingCenter.Send <Application, DisplayAlertMessage>(Application.Current, "ShowAlert",
                                                                        new DisplayAlertMessage {
                    Title = "Successful registration", Message = "Thanks for using Foods and Goods service.", Cancel = "OK"
                });

                GlobalSettings.LogiraniNarucilac = new Narucioci_Result {
                    Ime = Firstname.Value, Prezime = Lastname.Value, Username = Username.Value, BlokID = SelectedLocation.BlokID, DatumKreiranja = DateTime.Now
                };
                await App.Current.MainPage.Navigation.PushAsync(new ViewConditions());
            }
            catch (Exception ex)
            {
                IsBusy = false;
                MessagingCenter.Send <Application, DisplayAlertMessage>(Application.Current, "ShowAlert",
                                                                        new DisplayAlertMessage {
                    Title = "Error", Message = "Registration failed!", Cancel = "OK"
                });
            }
        }
        public async Task <ActionResult <Narucioci> > Register([FromBody] Narucioci obj)
        {
            if (obj == null)
            {
                return(BadRequest());
            }

            context.Narucioci.Add(obj);
            await context.SaveChangesAsync();

            return(Ok(obj));
        }
 public static Narucioci_Result GetNaruciociResultInstance(Narucioci obj)
 {
     return(obj == null ? null : new Narucioci_Result
     {
         KorisnikID = obj.KorisnikId,
         BadgeID = obj.BadgeId,
         DatumKreiranja = obj.DatumKreiranja,
         ImageUrl = obj.ImageUrl,
         LozinkaHash = obj.LozinkaHash,
         LozinkaSalt = obj.LozinkaSalt,
         Username = obj.Username,
         Ime = obj.Ime,
         Password = obj.Password, //obrisati ovo - no use
         Prezime = obj.Prezime,
         Adresa = obj.Adresa,
         BlokID = obj.BlokId,
         Blok = Blokovi_Result.GetBlokoviResultInstance(obj.Blok),
         Email = obj.Email,
         Telefon = obj.Telefon,
     });
 }