// POST api/RequestForm/SendChangeRequest
        public HttpResponseMessage SendChangeRequest(JObject json)
        {
            int managerID   = GetIDFromName((string)json["current"]["bazookaInfo"]["managerId"]);
            int f_managerID = GetIDFromName((string)json["future"]["bazookaInfo"]["managerId"]);

            HttpResponseMessage useForFailure = new HttpResponseMessage(HttpStatusCode.NotFound);

            if ((managerID == -1) && (f_managerID == -1))
            {
                useForFailure.Content = new StringContent("Both current and future managers were not found.");
                return(useForFailure);
            }
            else if (managerID == -1)
            {
                useForFailure.Content = new StringContent("Current manager was not found.");
                return(useForFailure);
            }
            else if (f_managerID == -1)
            {
                useForFailure.Content = new StringContent("Future manager was not found.");
                return(useForFailure);
            }

            RequestForm obj = makeRequestForm(json);

            Collection <string> to = new Collection <string>();

            to.Add("*****@*****.**");
            EmailSender emailer = new EmailSender("Coyote Moves Request ", to, "*****@*****.**", "", HttpContext.Current.Server.MapPath("/CoyoteMoves/CoyoteMovesTemplate.pdf"));

            emailer.sendMovesRequest(obj);

            RequestFormDB formDB = new RequestFormDB();

            formDB.StoreRequestFormInDatabaseAsPending(obj);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #2
0
        public void TestStoreRequestFormInDatabaseAsPending()
        {
            string test = "test";

            _req.CreatedByID = 301758;
            _req.Current.BazookaInfo.JobTitle           = "Intern";
            _req.Current.BazookaInfo.JobTemplate        = test;
            _req.Current.BazookaInfo.ManagerID          = 301757;
            _req.Current.BazookaInfo.Group              = "T1";
            _req.Current.BazookaInfo.SecurityItemRights = test;
            _req.Current.BazookaInfo.Department         = "IT";
            _req.Future.BazookaInfo.JobTitle            = "Intern";
            _req.Future.BazookaInfo.JobTemplate         = test;
            _req.Future.BazookaInfo.ManagerID           = 301757;
            _req.Future.BazookaInfo.Group = "T1";
            _req.Future.BazookaInfo.SecurityItemRights = test;
            _req.Future.BazookaInfo.Department         = "IT";

            _req.Current.DeskInfo.DeskNumber = test;
            _req.Current.DeskInfo.Office     = test;
            _req.Future.DeskInfo.DeskNumber  = test;
            _req.Future.DeskInfo.Office      = test;

            _req.Current.PhoneInfo.PhoneNumber = test;
            _req.Future.PhoneInfo.PhoneNumber  = test;

            _req.Current.UltiproInfo.Department = "IT";
            _req.Current.UltiproInfo.JobTitle   = "Intern";
            _req.Current.UltiproInfo.Other      = test;
            _req.Current.UltiproInfo.Supervisor = "Mitchell Hymel";
            _req.Future.UltiproInfo.Department  = "IT";
            _req.Future.UltiproInfo.JobTitle    = "Intern";
            _req.Future.UltiproInfo.Other       = test;
            _req.Future.UltiproInfo.Supervisor  = "Mitchell Hymel";

            _requester.StoreRequestFormInDatabaseAsPending(_req);
        }