Exemple #1
0
 public void InsertAlert(ViewAlert alert)
 {
     if (Session["SSAlert"] != null)
     {
         ((List <ViewAlert>)Session["SSAlert"]).Add(alert);
     }
     else
     {
         List <ViewAlert> alertList = new List <ViewAlert>();
         alertList.Add(alert);
         Session.Add("SSAlert", alertList);
         //Session["SS:Alert"] = alertList;
     }
 }
Exemple #2
0
        public void Initialize()
        {
            TestInitialiser.Initialise();
            crudOnAlerts = TestInitialiser.ninjectKernel.kernel.Get <ICrudOnAlerts>();
            crudOnUsers  = TestInitialiser.ninjectKernel.kernel.Get <ICrudOnUsers>();
            var viewUser = TestInitialiser.CreateUser();

            user = crudOnUsers.CreateOrUpdateUser(viewUser).Result;
            var viewAlert = new ViewAlert()
            {
                ProductName = productName, UserId = user.UserId
            };

            alert = Mapper.Map <Alert>(viewAlert);
        }
Exemple #3
0
        public async Task <IHttpActionResult> PostAlert([FromBody] ViewAlert viewAlert)
        {
            try
            {
                var username = await crudOnUsers.GetUsernameById(viewAlert.UserId);

                if (!await authorization.UserIsHimself(User.Identity.GetUserName(), username))
                {
                    return(Unauthorized());
                }

                var alert    = Mapper.Map <Alert>(viewAlert);
                var newAlert = await crudOnAlerts.AddAlert(alert);

                var newViewAlert = Mapper.Map <ViewAlert>(newAlert);
                return(Ok(newViewAlert));
            }
            catch (Exception ex)
            {
                return(throwExceptionToUser.Throw(ex));
            }
        }
        // GET: Alert/Details/5
        public ActionResult Details(int id)
        {
            // Create the string just as you would if you were typing it in the browser.
            string url = "AlertData/GetAlert/" + id;

            // Send the http request and get an http action response.
            HttpResponseMessage response = client.GetAsync(url).Result;

            // The http call worked.
            if (response.IsSuccessStatusCode)
            {
                ViewAlert ViewAlert = new ViewAlert();
                AlertDto  alertDto  = response.Content.ReadAsAsync <AlertDto>().Result;
                ViewAlert.alert = alertDto;

                if (alertDto.EventId != 0)
                {
                    EventDto eventDto = GetEventDto(alertDto.EventId);
                    ViewAlert.eventDto = eventDto;
                }
                return(View(ViewAlert));
            }
            return(RedirectToAction("Error"));
        }