Example #1
0
 public AddCampaign(CampaignData campaignData)
 {
     NavigationPage.SetBackButtonTitle(this, "");
     InitializeComponent();
     BindingContext = _addCampaignViewModel = new AddCampaignViewModel(Navigation);
     _addCampaignViewModel.Initialize(campaignData);
 }
Example #2
0
        public AddCampaignView(CampaignModel model)
        {
            InitializeComponent();
            DataContext = ViewModel = new AddCampaignViewModel(model);

            Owner   = Application.Current.MainWindow;
            Loaded += OnAddCampaignViewLoaded;
        }
Example #3
0
        public async Task <IActionResult> AddCampaign(AddCampaignViewModel addCampaignViewModel)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await userManager.GetUserAsync(HttpContext.User);

                var campaignId = await campaignService.AddCampaignAsync(addCampaignViewModel, currentUser);

                return(RedirectToAction(nameof(CampaignController.CampaignInfo), "Campaign", new { campaignId }));
            }

            return(View(addCampaignViewModel));
        }
Example #4
0
        public async Task <long> AddCampaignAsync(AddCampaignViewModel addCampaignViewModel, User user)
        {
            var campaign = new Campaign
            {
                Description = addCampaignViewModel.Description,
                Title       = addCampaignViewModel.Title,
                UserId      = user.Id,
                ExpiryDate  = SetExpiryDate(),
                Uri         = user.Uri
            };
            var result = await applicationContext.Campaigns.AddAsync(campaign);

            await applicationContext.SaveChangesAsync();

            return(campaign.CampaignId);
        }
Example #5
0
 public IActionResult Add(AddCampaignViewModel addCampaignViewModel)
 {
     if (ModelState.IsValid)
     {
         Campaign newCampaign = new Campaign()
         {
             ID                  = addCampaignViewModel.ID,
             CampaignCode        = addCampaignViewModel.CampaignCode,
             CampaignDescription = addCampaignViewModel.CampaignDescription,
             CampaignMonth       = addCampaignViewModel.CampaignMonth,
             CampaignYear        = addCampaignViewModel.CampaignYear
         };
         context.Campaigns.Add(newCampaign);
         context.SaveChanges();
         return(Redirect("/Campaign"));
     }
     return(View(addCampaignViewModel));
 }
Example #6
0
        public IActionResult Add()
        {
            AddCampaignViewModel addCampaignViewModel = new AddCampaignViewModel();

            return(View(addCampaignViewModel));
        }