Beispiel #1
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            try
            {
                Debug.WriteLine("Broker Creating... ");
                Address address = APIClient.GetAddress(collection);
                Broker  broker  = new Broker();
                broker.Address = address;
                broker.Mc      = collection["Mc"];
                Broker brokeradd = await APIClient.PostBroker(broker);

                Debug.WriteLine("Broker Created id " + brokeradd.Id);
                AuthServerUser authServerUser = await _userManager.GetUserAsync(User);

                authServerUser.brokerID = brokeradd.Id;
                IdentityResult result = await _userManager.UpdateAsync(authServerUser);

                if (result.Succeeded)
                {
                    Debug.WriteLine("Broker Details " + collection.Keys.Count);
                    return(RedirectToAction(nameof(Details), 1));
                }
                else
                {
                    foreach (var Error in result.Errors)
                    {
                        Debug.WriteLine("Broker Error " + Error.Description);
                    }
                    return(RedirectToAction(nameof(Create)));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Exception " + e.Message);
                return(View());
            }
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(int id, IFormCollection collection)
        {
            //try
            //{
            // TODO: Add update logic here
            Address        address        = APIClient.GetAddress(collection);
            AuthServerUser authServerUser = await _userManager.GetUserAsync(User);

            Broker broker = await APIClient.GetBroker(authServerUser.brokerID);

            address.Id       = broker.Address.Id;
            broker.Address   = address;
            broker.AddressId = broker.Address.Id;
            broker.Mc        = collection["Mc"];
            Broker brokeredit = await APIClient.EditBroker(broker);

            IdentityResult result = await _userManager.UpdateAsync(authServerUser);

            if (result.Succeeded)
            {
                Debug.WriteLine("Broker Details " + collection.Keys.Count);
                return(RedirectToAction(nameof(Details), 1));
            }
            else
            {
                foreach (var Error in result.Errors)
                {
                    Debug.WriteLine("Broker Error " + Error.Description);
                }
                return(RedirectToAction(nameof(Create)));
            }
            //}
            //catch
            //{
            //    return View();
            //}
        }
        // GET: Customer
        public async Task <ActionResult> Index()
        {
            AuthServerUser authServerUser = await _userManager.GetUserAsync(User);

            return(RedirectToAction(nameof(Details), authServerUser.customerID));
        }
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
            BeginContext(179, 4, true);
            WriteLiteral("\r\n\r\n");
            EndContext();
#line 7 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"

            ViewData["Title"] = "Home Page";
            AuthServerUser authServerUser = await UserManager.GetUserAsync(User);

#line default
#line hidden
            BeginContext(303, 12, true);
            WriteLiteral("\r\n\r\n<br />\r\n");
            EndContext();
#line 14 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
            if (SignInManager.IsSignedIn(User))
            {
#line default
#line hidden
#line 16 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                if (authServerUser.customerID == 0)
                {
#line default
#line hidden
                    BeginContext(405, 59, true);
                    WriteLiteral("        <a href=\"/Customer/Create\">Activate as Customer</a>");
                    EndContext();
#line 18 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // Activate Customer
                }
                else
                {
#line default
#line hidden
                    BeginContext(510, 56, true);
                    WriteLiteral("        <a href=\"/Customer/Details\">Customer Details</a>");
                    EndContext();
#line 22 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // Activate Customer
                }

#line default
#line hidden
                BeginContext(595, 12, true);
                WriteLiteral("    <br />\r\n");
                EndContext();
#line 25 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                if (authServerUser.carrierID == 0)
                {
#line default
#line hidden
                    BeginContext(655, 57, true);
                    WriteLiteral("        <a href=\"/Carrier/Create\">Activate as Carrier</a>");
                    EndContext();
#line 27 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // Activate Customer
                }
                else
                {
#line default
#line hidden
                    BeginContext(758, 54, true);
                    WriteLiteral("        <a href=\"/Carrier/Details\">Carrier Details</a>");
                    EndContext();
#line 31 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // Activate Customer
                }

#line default
#line hidden
                BeginContext(841, 12, true);
                WriteLiteral("    <br />\r\n");
                EndContext();
#line 34 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                if (authServerUser.brokerID == 0)
                {
#line default
#line hidden
                    BeginContext(900, 55, true);
                    WriteLiteral("        <a href=\"/Broker/Create\">Activate as Broker</a>");
                    EndContext();
#line 36 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // Activate Customer
                }
                else
                {
#line default
#line hidden
                    BeginContext(1001, 52, true);
                    WriteLiteral("        <a href=\"/Broker/Details\">Broker Details</a>");
                    EndContext();
#line 40 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // Activate Customer
                }

#line default
#line hidden
                BeginContext(1082, 12, true);
                WriteLiteral("    <br />\r\n");
                EndContext();
#line 43 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                if (authServerUser.customerID != 0 || authServerUser.brokerID != 0 || authServerUser.carrierID != 0)
                {
#line default
#line hidden
                    BeginContext(1208, 56, true);
                    WriteLiteral("        <a href=\"/EmployeeWeb\">Create Employee Login</a>");
                    EndContext();
#line 45 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
                    // ShiftAcceptWeb
                }

#line default
#line hidden
                BeginContext(1292, 12, true);
                WriteLiteral("    <br />\r\n");
                EndContext();
#line 49 "C:\Users\Red\source\repos\fleetAPI\AuthServer\Views\Home\Index.cshtml"
            }

#line default
#line hidden
            BeginContext(1307, 2, true);
            WriteLiteral("\r\n");
            EndContext();
        }