コード例 #1
0
        public ActionResult Mobile()
        {
            ReportRecipientGridViewModel model = new ReportRecipientGridViewModel();

            model.Areas = UserFunctions.GetAreasSelectList(_db);
            return(View(model));
        }
コード例 #2
0
        public ActionResult Edit(int id)
        {
            var selectedCompany = CompanyCookie.SelectedCompany;

            if (string.IsNullOrEmpty(selectedCompany))
            {
                return(RedirectToAction("Index"));
            }

            var model = _db.AlertRecipients.Find(id);

            if (model == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new AlertRecipientViewModel
            {
                Id     = id,
                AreaId = model.AreaId,
                Emails = model.Emails
            };

            viewModel.Areas = UserFunctions.GetAreasSelectList(_db, viewModel.AreaId);
            return(View(viewModel));
        }
コード例 #3
0
        public ActionResult Create()
        {
            AlertRecipientViewModel model = new AlertRecipientViewModel();

            model.Areas = UserFunctions.GetAreasSelectList(_db);
            return(View(model));
        }
コード例 #4
0
        // GET: AlertRecipient
        public ActionResult Index()
        {
            AlertRecipientGridViewModel model = new AlertRecipientGridViewModel();
            var selectedCompany = CompanyCookie.SelectedCompany;

            model.Companies       = UserFunctions.GetCompaniesSelectList(selectedCompany);
            model.SelectedCompany = selectedCompany;
            model.Areas           = UserFunctions.GetAreasSelectList(_db);

            return(View(model));
        }
コード例 #5
0
        public ActionResult Edit(AlertRecipientViewModel viewModel)
        {
            var alertrecipient = _db.AlertRecipients.Find(viewModel.Id);

            if (ModelState.IsValid)
            {
                //update only edit only fields
                alertrecipient.AreaId = viewModel.AreaId;
                alertrecipient.Emails = viewModel.Emails;

                _db.SaveChanges();
                TempData["SuccessMessage"] = "Alert Recipient has been updated successfully";

                return(RedirectToAction("Index"));
            }

            viewModel.Areas = UserFunctions.GetAreasSelectList(_db, viewModel.AreaId);
            return(View(viewModel));
        }
コード例 #6
0
        public ActionResult Create(ReportRecipientViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                ReportRecipient reportrecipient = new ReportRecipient()
                {
                    AreaId = viewModel.AreaId,
                    Emails = viewModel.Emails,
                };

                _db.ReportRecipients.Add(reportrecipient);
                _db.SaveChanges();

                TempData["SuccessMessage"] = "Report Recipient has been created successfully.";

                return(RedirectToAction("Index"));
            }

            viewModel.Areas = UserFunctions.GetAreasSelectList(_db, viewModel.AreaId);
            return(View(viewModel));
        }