Ejemplo n.º 1
0
        public async Task <IHttpActionResult> GetCurrentAccountRoles(string companyGUID)
        {
            List <AccountRole> dbRoleCollection = new List <AccountRole>();

            // Get the logged-in user.
            var currentUser = this.User as ServiceUser;

            Services.Log.Info("Find Company  [" + companyGUID + "] Staff Assignments for Current User");

            stranddContext context = new stranddContext();

            //Loading List of Account Roles from DB Context
            dbRoleCollection = await context.AccountRoles.Where(a => a.UserProviderID == currentUser.Id)
                               .Where(b => b.CompanyGUID == companyGUID).ToListAsync <AccountRole>();

            if (dbRoleCollection.Count > 0)
            {
                string responseText = "Returned Company  [" + companyGUID + "] Staff Assignments for Account [" + currentUser.Id + "] " + currentUser.Id;
                Services.Log.Info(responseText);
                return(Ok(dbRoleCollection));
            }
            else
            {
                string responseText = "No Company  [" + companyGUID + "] Staff Assignments for Account [" + currentUser.Id + "] " + currentUser.Id;
                Services.Log.Info(responseText);
                AccountRole noneRole = new AccountRole {
                    CompanyGUID = companyGUID, RoleAssignment = "NONE", UserProviderID = currentUser.Id
                };
                dbRoleCollection.Add(noneRole);
                return(Ok(dbRoleCollection));
            }
        }
        public async Task <HttpResponseMessage> NewCompany(CompanyRequest companyRequest)
        {
            Services.Log.Info("New Company Request [API]");

            stranddContext context = new stranddContext();

            //Checks for unique Company Name
            Company company = await context.Companies.Where(a => a.Name == companyRequest.Name).SingleOrDefaultAsync();

            if (company != null)
            {
                //Return Failed Response
                string responseText = "Company Already Exists [" + company.Name + "].";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }
            else
            {
                //Vehicle Creation
                Company newCompany = new Company
                {
                    Id   = Guid.NewGuid().ToString(),
                    Name = companyRequest.Name,
                    Type = companyRequest.Type
                };
                context.Companies.Add(newCompany);
                await context.SaveChangesAsync();

                string responseText = ("New Company Created #" + newCompany.Id);
                Services.Log.Info(responseText);

                return(this.Request.CreateResponse(HttpStatusCode.Created, responseText));
            }
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> RemoveStaffAssignment(AccountRoleRequest accountRoleRequest)
        {
            Services.Log.Info("Remove Staff Assignment Request [API]");
            string responseText;

            stranddContext context = new stranddContext();

            if (accountRoleRequest.RoleAssignment == null)
            {
                responseText = "No Role Assignment Defined"; Services.Log.Warn(responseText); return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }

            AccountRole lookupAccountRole = await context.AccountRoles.Where(a => a.UserProviderID == accountRoleRequest.UserProviderID)
                                            .Where(b => b.CompanyGUID == accountRoleRequest.CompanyGUID)
                                            .Where(c => c.RoleAssignment == accountRoleRequest.RoleAssignment).SingleOrDefaultAsync();

            if (lookupAccountRole == null)
            {
                responseText = "Staff Assignment Not Found";
                Services.Log.Info(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.NotFound, responseText));
            }
            else
            {
                //Staff Assignment Removal
                context.AccountRoles.Remove(lookupAccountRole);
                await context.SaveChangesAsync();

                responseText = "Staff Assignment Successfully Removed";
                Services.Log.Info(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.Created, responseText));
            }
        }
Ejemplo n.º 4
0
        public async Task <string> SendIncidentCurrentInvoice(string incidentGUID)
        {
            Services.Log.Info("Send Current Incident [" + incidentGUID + "] Invoice Initiated [HUB]");
            string responseText;

            //Retrieve Incident
            stranddContext context        = new stranddContext();
            Incident       returnIncident = context.Incidents.Find(incidentGUID);

            if (returnIncident != null)
            {
                if (SendGridController.SendCurrentIncidentInvoiceEmail(returnIncident, Services) == true)
                {
                    //Return Successful Response
                    responseText = "Sent Current Incident [" + incidentGUID + "] Invoice [HUB]";
                    Services.Log.Info(responseText);
                    return(responseText);
                }
                else
                {
                    //Return Successful Response
                    responseText = "No Payment Due for Current Incident [" + incidentGUID + "] Invoice [HUB]";
                    Services.Log.Info(responseText);
                    return(responseText);
                }
            }

            else
            {
                // Return Failed Response
                responseText = "Incident not found [" + incidentGUID + "] in the system";
                Services.Log.Warn(responseText);
                return(responseText);
            }
        }
        public async Task <HttpResponseMessage> ProviderClientExceptionGeneral(ExceptionLogRequest clientException)
        {
            Services.Log.Warn("Mobile Provider Client General Exception [API]");
            Services.Log.Warn(clientException.Exception);

            ExceptionEntry newException = new ExceptionEntry()
            {
                Id            = Guid.NewGuid().ToString(),
                ExceptionText = clientException.Exception,
                Source        = "MOBILE PROVIDER CLIENT"
            };

            stranddContext context = new stranddContext();

            context.ExceptionLog.Add(newException);

            await context.SaveChangesAsync();

            string responseText;

            responseText = "Exception Logged in Service";

            //Return Successful Response
            return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
        }
Ejemplo n.º 6
0
        public async Task <IEnumerable <IncidentInfo> > GetInactiveIncidents(int historyHours)
        {
            Services.Log.Info("Inactive Incident Log Requested [HUB]");
            List <Incident>     dbIncidentQuery            = new List <Incident>();
            List <IncidentInfo> inactiveIncidentCollection = new List <IncidentInfo>();

            stranddContext context = new stranddContext();
            DateTime       floorDate;

            if (historyHours == null || historyHours < 0)
            {
                floorDate = Convert.ToDateTime("01/01/2001");
            }
            else
            {
                TimeSpan spanBuffer = new TimeSpan(historyHours, 0, 0);
                floorDate = (DateTime.Now).Subtract(spanBuffer);
            }

            //Loading List of Active Incidents from DB Context
            dbIncidentQuery = await context.Incidents
                              .Where(b => b.StatusCode == "CANCELLED" || b.StatusCode == "DECLINED" || b.StatusCode == "COMPLETED" || b.StatusCode == "FAILED")
                              .Where(x => x.CreatedAt >= floorDate)
                              .ToListAsync <Incident>();

            foreach (Incident dbIncident in dbIncidentQuery)
            {
                inactiveIncidentCollection.Add(new IncidentInfo(dbIncident));
            }

            //Return Successful Response
            Services.Log.Info("Inactive Incident Log Returned [HUB]");
            return(inactiveIncidentCollection);
        }
Ejemplo n.º 7
0
        public async Task <HttpResponseMessage> CustomerUpdateVehicle(VehicleRequest vehicleRequest)
        {
            Services.Log.Info("Update Vehicle Request [API]");

            stranddContext context = new stranddContext();

            //Utilizes the Registration Number from Passed in Request as the Identifier
            Vehicle updateVehicle = await context.Vehicles.Where(a => a.RegistrationNumber == vehicleRequest.RegistrationNumber).SingleOrDefaultAsync();

            if (updateVehicle != null)
            {
                //Vehicle Updation
                updateVehicle.Make  = vehicleRequest.Make;
                updateVehicle.Model = vehicleRequest.Model;
                updateVehicle.Year  = vehicleRequest.Year;
                updateVehicle.Color = vehicleRequest.Color;

                await context.SaveChangesAsync();

                string responseText = "Updated Vehicle [VehicleGUID: " + updateVehicle.Id + "]";

                //Return Successful Response
                Services.Log.Info(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.Created, responseText));
            }
            else
            {
                //Return Failed Response
                Services.Log.Warn("Vehicle not found by Registration Number [" + vehicleRequest.RegistrationNumber + "]");
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, "Vehicle not found by Registration Number [" + vehicleRequest.RegistrationNumber + "]"));
            }
        }
        public async Task <IHttpActionResult> GetCurrentUserMobileCustomerClientIncidentStatusRequest()
        {
            // Get the logged-in user.
            var currentUser = this.User as ServiceUser;

            Services.Log.Info("Current User Mobile Customer Current Incident Status Request [API]");

            if (currentUser.Id != null)
            {
                stranddContext context = new stranddContext();
                Incident       accountincidentcheck = await context.Incidents
                                                      .Where(b => b.StatusCode != "CANCELLED" && b.StatusCode != "DECLINED" && b.StatusCode != "COMPLETED" && b.StatusCode != "FAILED")
                                                      .Where(c => c.ProviderUserID == currentUser.Id)
                                                      .SingleOrDefaultAsync();

                if (accountincidentcheck == null)
                {
                    return(NotFound());
                }
                else
                {
                    IncidentStatusRequest generatedStatusRequest = new IncidentStatusRequest(accountincidentcheck.Id);
                    //Return Successful Response
                    Services.Log.Info("Current User Mobile Customer Current Incident Status Request Generated and Returned [API]");
                    return(Ok(generatedStatusRequest));
                }
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 9
0
        public async Task <HttpResponseMessage> NewCostingSlab(CostingSlabRequest costingSlabRequest)
        {
            Services.Log.Info("New CostingSlab Request [API]");
            string responseText;

            stranddContext context = new stranddContext();

            CostingSlab newCostingSlab = new CostingSlab
            {
                Id                    = Guid.NewGuid().ToString(),
                IdentifierGUID        = costingSlabRequest.IdentifierGUID,
                ServiceType           = costingSlabRequest.ServiceType,
                Status                = costingSlabRequest.Status,
                StartTime             = costingSlabRequest.StartTime,
                EndTime               = costingSlabRequest.EndTime,
                BaseCharge            = costingSlabRequest.BaseCharge,
                BaseKilometersFloor   = costingSlabRequest.BaseKilometersFloor,
                ExtraKilometersCharge = costingSlabRequest.ExtraKilometersCharge

                                        // Version = new Byte[125],
                                        //CreatedAt = costingSlabRequest.StartTime,
                                        //UpdatedAt=costingSlabRequest.StartTime,
                                        //Deleted= false
            };

            context.CostingSlabs.Add(newCostingSlab);
            await context.SaveChangesAsync();

            responseText = "CostingSlab Successfully Generated";
            Services.Log.Info(responseText);
            return(this.Request.CreateResponse(HttpStatusCode.Created, responseText));
        }
        public HttpResponseMessage RoadZenResetPassword(LoginRequest passwordRequest)
        {
            Services.Log.Info("RoadZen Password Reset Request from Phone# [" + passwordRequest.Phone + "]");

            stranddContext context     = new stranddContext();
            Account        useraccount = context.Accounts.Where(a => a.Phone == passwordRequest.Phone).SingleOrDefault();

            if (useraccount != null)
            {
                if (useraccount.ProviderUserID.Substring(0, 7) != "RoadZen")
                {
                    string responseText = "Phone# Registered with Google";
                    Services.Log.Warn(responseText);
                    return(this.Request.CreateResponse(HttpStatusCode.BadRequest, WebConfigurationManager.AppSettings["RZ_MobileClientUserWarningPrefix"] + responseText));
                }
                else
                {
                    //Generate random characters from GUID
                    string newPassword = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8);

                    //Encrypt new Password
                    byte[] salt = RoadZenSecurityUtils.generateSalt();
                    useraccount.Salt = salt;

                    useraccount.SaltedAndHashedPassword = RoadZenSecurityUtils.hash(newPassword, salt);
                    Services.Log.Info("Password for Phone# [" + passwordRequest.Phone + "] Reset & Saved");

                    //Save Encrypted Password
                    context.SaveChanges();

                    //Prepare SendGrid Mail
                    SendGridMessage resetEmail = new SendGridMessage();

                    resetEmail.From = SendGridHelper.GetAppFrom();
                    resetEmail.AddTo(useraccount.Email);
                    resetEmail.Subject = "StrandD Password Reset";
                    resetEmail.Html    = "<h3>New Password</h3><p>" + newPassword + "</p>";
                    resetEmail.Text    = "New Password: "******"New Password Email Sent to [" + useraccount.Email + "]";
                    Services.Log.Info(responseText);
                    return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
                }
            }
            else
            {
                string responseText = "Phone Number Not Registered";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, WebConfigurationManager.AppSettings["RZ_MobileClientUserWarningPrefix"] + responseText));
            }
        }
        public HttpResponseMessage RoadZenAccountProviderRegistration(ProviderRegistrationRequest registrationRequest)
        {
            Services.Log.Info("New Account Provider Registration Request [API]");

            // Phone Number SS Validation
            if (!Regex.IsMatch(registrationRequest.Phone, "^[0-9]{10}$"))
            {
                Services.Log.Warn("Invalid phone number (must be 10 numeric digits");
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid phone number (must be 10 numeric digits"));
            }
            if (!RegexUtilities.IsValidEmail(registrationRequest.Email))
            {
                Services.Log.Warn("Invalid e-mail address");
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid e-mail address"));
            }

            // Get the logged-in user.
            var currentUser = this.User as ServiceUser;

            stranddContext context = new stranddContext();

            Account account = context.Accounts.Where(a => a.Phone == registrationRequest.Phone).SingleOrDefault();

            if (account != null)
            {
                string responseText = "Phone Number Already Registered";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, WebConfigurationManager.AppSettings["RZ_MobileClientUserWarningPrefix"] + responseText));
            }

            //Password SS Validation
            if (registrationRequest.Password.Length < 6)
            {
                Services.Log.Warn("Invalid password (at least 6 chars required)");
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid password (at least 6 chars required)"));
            }

            byte[] salt = RoadZenSecurityUtils.generateSalt();

            Guid guid = Guid.NewGuid();

            Account newUserAccount = new Account
            {
                Id                      = guid.ToString(),
                Name                    = registrationRequest.Name,
                Phone                   = registrationRequest.Phone,
                Email                   = registrationRequest.Email,
                ProviderUserID          = "RoadZen:" + guid.ToString("N").ToUpper(),
                Salt                    = salt,
                SaltedAndHashedPassword = RoadZenSecurityUtils.hash(registrationRequest.Password, salt)
            };

            context.Accounts.Add(newUserAccount);
            context.SaveChanges();

            Services.Log.Info("Account for [" + newUserAccount.ProviderUserID + "] has been created");
            return(this.Request.CreateResponse(HttpStatusCode.Created, "Account for [" + newUserAccount.ProviderUserID + "] has been created"));
        }
Ejemplo n.º 12
0
        public HttpResponseMessage CustomerIncidentPaymentView(string incidentGUID)
        {
            HttpResponseMessage response;

            Services.Log.Info("Customer Incident [" + incidentGUID + "] Payment View Requested [API]");

            Uri          redirectURI;
            string       paymentService;
            IncidentInfo paymentIncident;

            stranddContext context        = new stranddContext();
            Incident       returnIncident = context.Incidents.Find(incidentGUID);

            if (returnIncident != null)
            {
                paymentService  = "Instamojo"; //WILL ADAPT AS NEW PAYMENT SERVICES ADDED
                paymentIncident = new IncidentInfo(incidentGUID);
            }
            else
            {
                paymentService = "Not Found"; paymentIncident = new IncidentInfo();
            }


            if (paymentService == "Instamojo")
            {
                string instamojoIncidentDataField = WebConfigurationManager.AppSettings["RZ_InstamojoIncidentDataField"]; // "data_Field_25373"

                var redirectQuery = HttpUtility.ParseQueryString(string.Empty);

                redirectQuery["data_readonly"] = "data_amount";
                redirectQuery["embed"]         = "form";

                redirectQuery["data_amount"] = (paymentIncident.ServiceFee - paymentIncident.PaymentAmount).ToString();
                redirectQuery["data_email"]  = paymentIncident.IncidentUserInfo.Email.ToString();
                redirectQuery["data_name"]   = paymentIncident.IncidentUserInfo.Name.ToString();
                redirectQuery["data_phone"]  = paymentIncident.IncidentUserInfo.Phone.ToString();

                redirectQuery[("data_" + instamojoIncidentDataField)] = incidentGUID;
                redirectQuery["data_hidden"] = ("data_" + instamojoIncidentDataField);

                string urlFullString = WebConfigurationManager.AppSettings["RZ_InstamojoBaseURL"].ToString() + "?" + redirectQuery.ToString();
                redirectURI = new Uri(urlFullString);

                response = Request.CreateResponse(HttpStatusCode.Moved);
                response.Headers.Location = redirectURI;
                Services.Log.Info("Customer Incident Payment View [" + urlFullString + "] Returned [VIEW]");
            }
            else
            {
                response = Request.CreateResponse("<H1>No Incident Found</H1>");
                Services.Log.Warn("Customer Incident [" + incidentGUID + "] Not Found [VIEW]");
            }

            //Return Generated Response
            return(response);
        }
        public async Task <HttpResponseMessage> GetSmsStatusByMessageIDs(String MessageIDs)
        {
            String strreturn;
            String strAPI   = ConfigurationManager.AppSettings["OutboundSmsAPI"];
            String senderid = ConfigurationManager.AppSettings["OutboundSmsSenderID"];

            String         sURL    = "http://global.sinfini.com/api/v3/index.php?method=sms" + "&api_key=" + strAPI + "&format=json&id=" + MessageIDs + "&numberinfo=1";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sURL);

            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    // return reader.ReadToEnd();
                    strreturn = reader.ReadToEnd();
                }
            }
            catch (WebException ex)
            {
                WebResponse errorResponse = ex.Response;
                using (Stream responseStream = errorResponse.GetResponseStream())
                {
                    StreamReader reader    = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                    String       errorText = reader.ReadToEnd();
                    //log errorText
                }
                throw;
            }

            stranddContext context = new stranddContext();

            CommunicationEntry update = await context.CommunicationLog.Where(a => a.Source == MessageIDs).SingleOrDefaultAsync();

            String responseText = String.Empty;

            if (update != null)
            {
                JObject obj       = JObject.Parse(strreturn);
                string  Messageid = String.Empty;

                update.Source = obj["message"].ToString();

                await context.SaveChangesAsync();

                responseText = "Status Update MessgeId: " + MessageIDs;

                //Return Successful Response
                Services.Log.Info(responseText);
            }

            //string responseText = strreturn;

            return(this.Request.CreateResponse(HttpStatusCode.Created, responseText));
        }
Ejemplo n.º 14
0
        public async Task <HttpResponseMessage> NewStaffAssignment(AccountRoleRequest accountRoleRequest)
        {
            Services.Log.Info("New Staff Assignment Request [API]");
            string responseText;

            stranddContext context = new stranddContext();

            //Checks for existing Link References
            Account lookupAccount = await context.Accounts.Where(a => a.ProviderUserID == accountRoleRequest.UserProviderID).SingleOrDefaultAsync();

            Company lookupCompany = await context.Companies.Where(a => a.Id == accountRoleRequest.CompanyGUID).SingleOrDefaultAsync();

            if (lookupAccount == null)
            {
                responseText = "Account not found [" + accountRoleRequest.UserProviderID + "]"; Services.Log.Warn(responseText); return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }
            if (lookupCompany == null)
            {
                responseText = "Company not found [" + accountRoleRequest.CompanyGUID + "]"; Services.Log.Warn(responseText);  return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }
            if (accountRoleRequest.RoleAssignment == null)
            {
                responseText = "No Role Assignment Defined"; Services.Log.Warn(responseText); return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }

            AccountRole lookupAccountRole = await context.AccountRoles.Where(a => a.UserProviderID == accountRoleRequest.UserProviderID)
                                            .Where(b => b.CompanyGUID == accountRoleRequest.CompanyGUID)
                                            .Where(c => c.RoleAssignment == accountRoleRequest.RoleAssignment).SingleOrDefaultAsync();

            if (lookupAccountRole == null)
            {
                //Staff Assignment Creation
                AccountRole newAccountRole = new AccountRole
                {
                    Id             = Guid.NewGuid().ToString(),
                    RoleAssignment = accountRoleRequest.RoleAssignment,
                    CompanyGUID    = accountRoleRequest.CompanyGUID,
                    UserProviderID = accountRoleRequest.UserProviderID
                };

                context.AccountRoles.Add(newAccountRole);
                await context.SaveChangesAsync();

                responseText = "Staff Assignment Successfully Generated";
                Services.Log.Info(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.Created, responseText));
            }
            else
            {
                responseText = "Staff Assignment Already Exists";
                Services.Log.Info(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
            }
        }
Ejemplo n.º 15
0
        public async Task <string> ProviderAcceptJob(string jobTag)
        {
            Services.Log.Info("Provider Job Acceptance Request [Hub]");
            string responseText;

            var currentUserID = ((ServiceUser)Context.User).Id;

            stranddContext context = new stranddContext();

            //Retrieve Incident
            Incident updateIncident = await(from r in context.Incidents where (r.Id == jobTag) select r).FirstOrDefaultAsync();

            if (updateIncident != null)
            {
                updateIncident.StatusCode            = "PROVIDER-FOUND";
                updateIncident.StatusCustomerConfirm = false;
                updateIncident.StatusProviderConfirm = false;
            }
            else
            {
                // Return Failed Response
                responseText = "Incident not found [" + jobTag + "] in the system";
                Services.Log.Warn(responseText);
                return(responseText);
            }

            //Save record
            await context.SaveChangesAsync();

            Services.Log.Info("Incident [" + updateIncident.Id + "] Job Accepted by Provider [" + currentUserID + "]");

            Dictionary <string, string> pushData = new Dictionary <string, string>();

            pushData.Add("status", "PROVIDER-FOUND");
            pushData.Add("incidentGUID", jobTag);

            //Notify Particular Connected Customer User through SignalR
            Clients.Group(updateIncident.ProviderUserID).updateMobileClientStatus(pushData);
            Services.Log.Info("Mobile Client [" + updateIncident.ProviderUserID + "] Status Update Payload Sent");

            //Notifying Connect WebClients with IncidentInfo Package
            Clients.All.updateIncidentStatusAdmin(new IncidentInfo(updateIncident));
            Services.Log.Info("Connected Clients Updated");

            IncidentController.RevokeProviderJobs(updateIncident, Services);
            Services.Log.Info("Provider Jobs Revoked");

            await HistoryEvent.logHistoryEventAsync("INCIDENT_STATUS_PROVIDER", updateIncident.StatusCode, updateIncident.Id, null, null, currentUserID);

            //Return Successful Response
            responseText = "Status Updated";
            return(responseText);
        }
Ejemplo n.º 16
0
        public async Task <string> UpdateDetails(IncidentDetailsRequest detailsRequest)
        {
            Services.Log.Info("Incident Details Update Request [Hub]");
            string responseText;

            var currentUserID = ((ServiceUser)Context.User).Id;

            stranddContext context = new stranddContext();

            //Retrieve Incident
            Incident updateIncident = await(from r in context.Incidents where (r.Id == detailsRequest.IncidentGUID) select r).FirstOrDefaultAsync();

            //Find the Incident to Edit and return Bad Response if not found
            if (updateIncident != null)
            {
                //Check for Submitted Status and Update
                if (detailsRequest.Notes != null)
                {
                    updateIncident.StaffNotes = detailsRequest.Notes;
                }

                //Check for Submitted Pricing and Update
                if (detailsRequest.ConcertoCaseID != null)
                {
                    updateIncident.ConcertoCaseID = detailsRequest.ConcertoCaseID;
                }
            }
            else
            {
                // Return Failed Response
                responseText = "Incident not found [" + detailsRequest.IncidentGUID + "] in the system";
                Services.Log.Warn(responseText);
                return(responseText);
            }

            //Save record
            await context.SaveChangesAsync();

            responseText = "Incident [" + updateIncident.Id + "] Details Updated";
            Services.Log.Info(responseText);


            //Notifying Connected WebClients with IncidentInfo Package
            Clients.All.updateIncidentDetailsAdmin(new IncidentInfo(updateIncident));
            Services.Log.Info("Connected Web Clients Updated");

            await HistoryEvent.logHistoryEventAsync("INCIDENT_DETAILS_ADMIN", null, updateIncident.Id, currentUserID, null, null);

            //Return Successful Response
            return(responseText);
        }
Ejemplo n.º 17
0
        public async Task <string> UpdateCosting(IncidentCostingRequest costingRequest)
        {
            Services.Log.Info("Update Incident Costing Request [HUB]");
            string responseText;

            IncidentInfo infoOutput;

            //Get Defaults From Configuration and overrride from Request (To be Modified in Expansions)

            string companyGUID = (costingRequest.ProviderIdentifierGUID == null || costingRequest.ProviderIdentifierGUID == "") ? WebConfigurationManager.AppSettings["RZ_DefaultProviderCompany"] : costingRequest.ProviderIdentifierGUID;
            string policyGUID  = (costingRequest.CustomerIdentifierGUID == null || costingRequest.CustomerIdentifierGUID == "") ? WebConfigurationManager.AppSettings["RZ_DefaultCustomerPolicy"] : costingRequest.CustomerIdentifierGUID;

            stranddContext context = new stranddContext();

            CostingSlab providerSlab = new CostingSlab();

            providerSlab = await(from r in context.CostingSlabs where (r.IdentifierGUID == companyGUID && r.ServiceType == costingRequest.ServiceType && r.Status == "CURRENT") select r).FirstOrDefaultAsync();
            if (providerSlab == null)
            {
                responseText = "Provider Company Costing Slab Not Found"; Services.Log.Warn(responseText);
            }
            else
            {
                IncidentController.SaveCostingSlabAsync(costingRequest, providerSlab, "PROVIDER", Services);
            }

            CostingSlab customerSlab = new CostingSlab();

            customerSlab = await(from r in context.CostingSlabs where (r.IdentifierGUID == policyGUID && r.ServiceType == costingRequest.ServiceType && r.Status == "CURRENT") select r).FirstOrDefaultAsync();

            if (customerSlab == null)
            {
                responseText = "Customer Policy Costing Slab Not Found"; Services.Log.Warn(responseText);
            }
            else
            {
                await IncidentController.SaveCostingSlabAsync(costingRequest, customerSlab, "CUSTOMER", Services);

                responseText = "Incident Costings Request Processed";

                infoOutput = new IncidentInfo(costingRequest.IncidentGUID);

                //Web Client Notifications
                IHubContext hubContext = Services.GetRealtime <IncidentHub>();
                hubContext.Clients.All.updateIncidentCostingAdmin(infoOutput);
                Services.Log.Info("Connected Clients Generated");
            }

            return(responseText);
        }
Ejemplo n.º 18
0
        public async Task <IHttpActionResult> GetAllCostingSlab()
        {
            Services.Log.Info("Full CostingSlab Log Requested [API]");
            List <CostingSlab> dbCostingSlabCollection = new List <CostingSlab>();

            stranddContext context = new stranddContext();

            //Loading List of CostingSlab from DB Context
            dbCostingSlabCollection = await(context.CostingSlabs.OrderBy(a => a.Status)).ToListAsync <CostingSlab>();

            //Return Successful Response
            Services.Log.Info("Full CostingSlab Log Returned [API]");
            return(Ok(dbCostingSlabCollection));
        }
Ejemplo n.º 19
0
        public async Task <IHttpActionResult> GetAllPayments()
        {
            Services.Log.Info("Payment Log Requested [API]");
            List <Payment> dbPaymentCollection = new List <Payment>();

            stranddContext context = new stranddContext();

            //Loading List of Accounts from DB Context
            dbPaymentCollection = await(context.Payments).ToListAsync <Payment>();

            //Return Successful Response
            Services.Log.Info("Payment Log Returned [API]");
            return(Ok(dbPaymentCollection));
        }
Ejemplo n.º 20
0
        public async Task <IHttpActionResult> GetAllVehicleInfos()
        {
            Services.Log.Info("Vehicle Log Requested [API]");
            List <Vehicle> dbVehicleCollection = new List <Vehicle>();

            stranddContext context = new stranddContext();

            //Loading List of Incidents from DB Context
            dbVehicleCollection = await(context.Vehicles).ToListAsync <Vehicle>();

            //Return Successful Response
            Services.Log.Info("Vehicle Log Returned [API]");
            return(Ok(dbVehicleCollection));
        }
        public async Task <IHttpActionResult> GetAllExceptions()
        {
            Services.Log.Info("Exception Log Requested [API]");
            List <ExceptionEntry> dbExceptionCollection = new List <ExceptionEntry>();

            stranddContext context = new stranddContext();

            //Loading List of Accounts from DB Context
            dbExceptionCollection = await(context.ExceptionLog).ToListAsync <ExceptionEntry>();

            //Return Successful Response
            Services.Log.Info("Exception Log Returned [API]");
            return(Ok(dbExceptionCollection));
        }
        public async Task <IHttpActionResult> GetAllHistoryLog()
        {
            Services.Log.Info("History Log Requested [API]");
            List <HistoryEvent> dbHistoryLog = new List <HistoryEvent>();

            stranddContext context = new stranddContext();

            //Loading Log of History Events from DB Context
            dbHistoryLog = await(context.HistoryLog).ToListAsync <HistoryEvent>();

            //Return Successful Response
            Services.Log.Info("History Log Returned [API]");
            return(Ok(dbHistoryLog));
        }
        public async Task <HttpResponseMessage> CustomerUpdateRating(IncidentRatingRequest ratingRequest)
        {
            Services.Log.Info("Incident Rating Update Request [API]");
            string responseText;

            // Get the logged-in user.
            var currentUser = this.User as ServiceUser;

            stranddContext context = new stranddContext();

            //Retrieve Incident
            Incident updateIncident = await(from r in context.Incidents where (r.Id == ratingRequest.IncidentGUID) select r).FirstOrDefaultAsync();

            if (updateIncident != null)
            {
                //Edit Incident
                if (ratingRequest.Rating != 0)
                {
                    updateIncident.Rating = ratingRequest.Rating;
                }

                if (ratingRequest.Comments != null)
                {
                    updateIncident.CustomerComments = ratingRequest.Comments;
                }
            }
            else
            {
                // Return Failed Response
                responseText = "Incident [" + ratingRequest.IncidentGUID + "] is not found in the system";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }

            //Save record
            await context.SaveChangesAsync();

            responseText = "Incident [" + updateIncident.Id + "] Rating Updated";
            Services.Log.Info(responseText);

            //Notifying Connect WebClients with IncidentInfo Package
            IHubContext hubContext = Services.GetRealtime <IncidentHub>();

            hubContext.Clients.All.updateIncidentRatingCustomer(new IncidentInfo(updateIncident));
            Services.Log.Info("Connected Web Clients Updated");

            await HistoryEvent.logHistoryEventAsync("INCIDENT_RATING_CUSTOMER", null, updateIncident.Id, null, currentUser.Id, null);

            return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
        }
Ejemplo n.º 24
0
        public async Task <IHttpActionResult> GetAllStaffAssignments()
        {
            Services.Log.Info("Full Staff Assisgnments Log Requested [API]");
            List <AccountRole> dbAccountRoleCollection = new List <AccountRole>();

            stranddContext context = new stranddContext();

            //Loading List of Incidents from DB Context
            dbAccountRoleCollection = await(context.AccountRoles).ToListAsync <AccountRole>();

            //Return Successful Response
            Services.Log.Info("Full Staff Assisgnments Log Returned [API]");
            return(Ok(dbAccountRoleCollection));
        }
        public async Task <IHttpActionResult> GetAllCompanies()
        {
            Services.Log.Info("Company Log Requested [API]");
            List <Company> dbCompanyCollection = new List <Company>();

            stranddContext context = new stranddContext();

            //Loading List of Incidents from DB Context
            dbCompanyCollection = await(context.Companies).ToListAsync <Company>();

            //Return Successful Response
            Services.Log.Info("Company Log Returned [API]");
            return(Ok(dbCompanyCollection));
        }
        public async Task <HttpResponseMessage> CustomerClientExceptionContact(ExceptionContactRequest contactRequest)
        {
            Services.Log.Warn("Mobile Customer Client Exception Contact Request [API]");
            string responseText = "";

            IHubContext hubContext = Services.GetRealtime <IncidentHub>();

            CommunicationEntry newCommunication = new CommunicationEntry()
            {
                Id         = Guid.NewGuid().ToString(),
                Tag        = contactRequest.ContactPhone,
                IncidentID = contactRequest.IncidentGUID,
                Type       = "MOBILE CUSTOMER CLIENT EXCEPTION CONTACT REQUEST",
                Status     = "SUBMITTED",
                StartTime  = DateTime.Now
            };

            stranddContext context = new stranddContext();

            context.CommunicationLog.Add(newCommunication);

            await context.SaveChangesAsync();

            responseText = "Communication Logged in Service";
            Services.Log.Info(responseText);
            responseText = "";

            if (contactRequest.ContactPhone != null)
            {
                responseText += "CONTACT CUSTOMER on Phone [" + contactRequest.ContactPhone + "] ";
            }

            if (contactRequest.IncidentGUID != null)
            {
                responseText += " | Exception on Incident [" + contactRequest.IncidentGUID + "]";
                //hubContext.Clients.All.updateIncidentCustomerError(responseText);
            }

            Services.Log.Warn(responseText);

            hubContext.Clients.All.notifyCustomerClientExceptionContact(new CommunicationInfo(newCommunication));
            Services.Log.Info("Connected Clients Updated");

            //Return Successful Response
            return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));

            //PENDING TO ADD: Incident Updation with Error
        }
        public async Task <HttpResponseMessage> UpdateDetails(IncidentDetailsRequest detailsRequest)
        {
            Services.Log.Info("Incident Details Update Request [API]");
            string responseText;

            stranddContext context = new stranddContext();

            //Retrieve Incident
            Incident updateIncident = await(from r in context.Incidents where (r.Id == detailsRequest.IncidentGUID) select r).FirstOrDefaultAsync();

            //Find the Incident to Edit and return Bad Response if not found
            if (updateIncident != null)
            {
                //Check for Submitted Status and Update
                if (detailsRequest.Notes != null)
                {
                    updateIncident.StaffNotes = detailsRequest.Notes;
                }

                //Check for Submitted Pricing and Update
                if (detailsRequest.ConcertoCaseID != null)
                {
                    updateIncident.ConcertoCaseID = detailsRequest.ConcertoCaseID;
                }
            }
            else
            {
                // Return Failed Response
                responseText = "Incident [" + detailsRequest.IncidentGUID + "] is not found in the system";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }

            //Save record
            await context.SaveChangesAsync();

            responseText = "Incident [" + updateIncident.Id + "] Details Updated";
            Services.Log.Info(responseText);

            //Notifying Connect WebClients with IncidentInfo Package
            IHubContext hubContext = Services.GetRealtime <IncidentHub>();

            hubContext.Clients.All.updateIncidentDetailsAdmin(new IncidentInfo(updateIncident));
            Services.Log.Info("Connected Clients Updated");

            //Return Successful Response
            return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
        }
        public async Task <HttpResponseMessage> OperatorConfirmCallRequest(OperatorCallRequestConfirmationRequest communicationRequest)
        {
            Services.Log.Info("Operator Call Request Confirmation Requested [API]");
            string responseText;

            // Get the logged-in user.
            var currentUser = this.User as ServiceUser;

            stranddContext context = new stranddContext();

            //Retrieve Communication
            CommunicationEntry updateCommunication = await(from r in context.CommunicationLog where (r.Id == communicationRequest.CommunicationGUID) select r).FirstOrDefaultAsync();

            if (updateCommunication != null)
            {
                if (updateCommunication.Status == "CONFIRMED")
                {
                    responseText = "Already Confirmed - Communication [" + communicationRequest.CommunicationGUID + "] ";
                    Services.Log.Info(responseText);
                    return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
                }

                else
                {
                    //Edit Communication
                    updateCommunication.OperatorID = currentUser.Id;
                    updateCommunication.Status     = "CONFIRMED";
                    updateCommunication.EndTime    = DateTime.Now;
                }
            }
            else
            {
                // Return Failed Response
                responseText = "Not Found - Communication [" + communicationRequest.CommunicationGUID + "] ";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.NotFound, responseText));
            }

            //Save record
            await context.SaveChangesAsync();

            responseText = "Operator Confirmed - Communication [" + updateCommunication.Id + "] ";
            Services.Log.Info(responseText);

            //await HistoryEvent.logHistoryEventAsync("COMMUNICATION_REQUESTCONFIRMATION_OPERATOR", null, updateCommunication.Id, null, null, null);

            return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
        }
Ejemplo n.º 29
0
        public async Task <IHttpActionResult> GetCostingSlabInfo(string CostingSlabid)
        {
            List <CostingSlab> dbCostingSlab = new List <CostingSlab>();

            // Get the logged-in user.
            // var currentUser = this.User as ServiceUser;

            Services.Log.Info("CostingSlabID [" + CostingSlabid + "] CostingSlab Information Requested [API]");

            stranddContext context = new stranddContext();

            dbCostingSlab = await context.CostingSlabs.Where(a => a.Id == CostingSlabid)
                            .ToListAsync <CostingSlab>();

            //Return Successful Response
            Services.Log.Info("CostingSlabID [" + CostingSlabid + "] CostingSlab Information Returned");
            return(Ok(dbCostingSlab));
        }
        public async Task <HttpResponseMessage> CustomerCancel(IncidentStatusRequest statusRequest)
        {
            Services.Log.Info("Incident Cancellation Request [API]");
            string responseText;

            // Get the logged-in user.
            var currentUser = this.User as ServiceUser;

            stranddContext context = new stranddContext();

            //Retrieve Incident
            Incident updateIncident = await(from r in context.Incidents where (r.Id == statusRequest.IncidentGUID) select r).FirstOrDefaultAsync();

            //Find the Incident to Cancel and return Bad Response if not found
            if (updateIncident == null)
            {
                // Return Failed Response
                responseText = "Incident [" + statusRequest.IncidentGUID + "] is not found in the system";
                Services.Log.Warn(responseText);
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, responseText));
            }
            else
            {
                updateIncident.StatusCode            = "CANCELLED";
                updateIncident.StatusCustomerConfirm = true;
                updateIncident.StatusProviderConfirm = false;

                //Save record
                await context.SaveChangesAsync();

                responseText = "Incident [" + updateIncident.Id + "] Cancelled by Customer";
                Services.Log.Info(responseText);

                //Notifying Connect WebClients with IncidentInfo Package
                IHubContext hubContext = Services.GetRealtime <IncidentHub>();
                hubContext.Clients.All.updateIncidentStatusCustomerCancel(new IncidentInfo(updateIncident));
                Services.Log.Info("Connected Clients Updated");

                await HistoryEvent.logHistoryEventAsync("INCIDENT_CANCEL_CUSTOMER", null, updateIncident.Id, null, currentUser.Id, null);

                //Return Successful Response
                return(this.Request.CreateResponse(HttpStatusCode.OK, responseText));
            }
        }
Ejemplo n.º 31
0
        //Takes in VehicleGUID for Constructor
        public VehicleInfo(string vehicleGUID)
        {
            stranddContext context = new stranddContext();

            Vehicle returnVehicle = context.Vehicles.Find(vehicleGUID);

            if (returnVehicle == null)
            {
                this.VehicleGUID = "NO ASSOCIATED VEHICLE";
                this.RegistrationNumber = "NO ASSOCIATED VEHICLE";
                this.Description = "NO ASSOCIATED VEHICLE";

            }
            else
            {
                this.VehicleGUID = returnVehicle.Id;
                this.Make = returnVehicle.Make;
                this.Model = returnVehicle.Model;
                this.Year = returnVehicle.Year;
                this.Color = returnVehicle.Color;
                this.RegistrationNumber = returnVehicle.RegistrationNumber;
                this.Description = returnVehicle.Year + " " + returnVehicle.Color + " " + returnVehicle.Make + " " + returnVehicle.Model;
            }
        }