public void ShowAdForm(IMainView MainView)
        {
            var frm = (Form)MainView;

            frm.Hide();

            AdController AdController = new AdController();
            AdForm       AdForm       = (AdForm)WindowFormsFactory.CreateAdView(this);

            AdForm.AdjustCreateView();

            AdController.ShowAdForm(AdForm);
        }
        public void ShowAdForm(int Id, IMainView MainView)
        {
            if (CurrentUser == null)
            {
                MessageBox.Show("Morate biti prijavljeni da biste vidjeli cijeli oglas");
                return;
            }

            var frm = (Form)MainView;

            frm.Hide();

            AdForm AdForm = (AdForm)WindowFormsFactory.CreateAdView(this);

            WalkerAd no = AdRepository.GetWalkerAd(Id);

            if (no != null)
            {
                AdForm.HideCreate();
            }

            OwnerAd po = AdRepository.GetOwnerAd(Id);

            if (po != null)
            {
                AdForm.HideCreate();
            }

            if (no == null && po == null)
            {
                AdForm.AdjustCreateView();
            }

            if (CurrentUser == null)
            {
                MessageBox.Show("Morate biti prijavljeni da biste vidjeli cijeli oglas");
                return;
            }


            if (GetOwner(Id, AdRepository).Username != CurrentUser.Username)
            {
                AdForm.NotUsersAd();
            }



            AdController AdController = new AdController();

            AdController.ShowAdForm(AdForm, Id, UserRepository, AdRepository, CurrentUser);
        }
 public static void LogIn(LoginViewModel lvm)
 {
     if (AuthController.LogIn(lvm))
     {
         HomeForm.LogIn(lvm);
         LogInForm.Close();
         AdForm?.DetermineLoggedIn();
     }
     else
     {
         MessageBox.Show("Could not log you in with these credentials.",
                         "Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public async Task <ActionResult <Ad> > PostAd([FromForm] AdForm adForm)
        {
            var ad = new Ad
            {
                CategoryId  = adForm.CategoryId,
                Title       = adForm.Title,
                Price       = adForm.Price,
                Description = adForm.Description,
                CreatedBy   = User.Identity.Name
            };

            ad.Image = await SaveFile(adForm.Image);

            _context.Ads.Add(ad);
            await _context.SaveChangesAsync();

            await _queueService.SendMessage($"{ad.Id}###{ad.Image}");

            return(CreatedAtAction("GetAd", new { id = ad.Id }, ad));
        }
 public static void ViewAd(string id)
 {
     AdForm?.Close();
     AdForm = new AdForm(AdController.GetAd(id));
     AdForm.Show();
 }
 public static void LogOut()
 {
     AuthController.LogOut();
     HomeForm.LogOut();
     AdForm?.DetermineLoggedIn();
 }