Ejemplo n.º 1
0
        public bool UpdateDocumentStatus(long docId, DocumentStatus status)
        {
            DriverDocument doc = docMgmt.GetById(docId);

            doc.Status = (short)status;
            return(docMgmt.Update(doc));
        }
Ejemplo n.º 2
0
        private bool SaveDocumentInfo(string authenticationToken,string ssn,string licenseNumber,string vehicleNumber)
        {
            //make sure the user token is for the driver type user
            var user = GetUserByToken(authenticationToken);
            if (user == null)
                throw new ArgumentException("user");

            if (user.UserType != (short)UserType.Driver)
                throw new Exception("The requested user is not a driver.");

            DriverDocument doc = svc.GetDocumentByUserId(user.Id);
            if (doc == null)
            {
                doc = new DriverDocument();
                doc.UserId = user.Id;
                doc.LicenseNumber = licenseNumber;
                doc.SSN = ssn;
                doc.VehicleNumber = vehicleNumber;
                doc.Status = (short)DocumentStatus.Pending;
                svc.InsertDocumentInfo(doc);
            }
            else
            {
                doc.LicenseNumber = licenseNumber;
                doc.SSN = ssn;
                doc.VehicleNumber = vehicleNumber;
                svc.UpdateDocumentInfo(doc);
            }
            return true;
        }
Ejemplo n.º 3
0
        private void LoadDriverDocumentDetails()
        {
            long docId = FetchDocumentIdFromQueryString();

            DriverDocument doc = usrSvc.GetDocumentById(docId);

            if (doc == null)
            {
                throw new Exception("Document not found with the ID provided");
            }

            lblFirstName.Text     = doc.User.Firstname;
            lblLastName.Text      = doc.User.Lastname;
            lblEmail.Text         = doc.User.Email;
            lblDocumentId.Text    = doc.Id.ToString();
            lblLicenseNumber.Text = doc.LicenseNumber;
            lblSSN.Text           = doc.SSN.ToString();
            lblVehicleNumber.Text = doc.VehicleNumber;

            imgPreviewVehicleImage1.ImageUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document) + "type=" + DocumentType.VehicleImage1.ToString() + "&docId=" + docId;
            imgPreviewVehicleImage2.ImageUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document) + "type=" + DocumentType.VehicleImage2.ToString() + "&docId=" + docId;
            imgPreviewVehicleImage3.ImageUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document) + "type=" + DocumentType.LicenseImage.ToString() + "&docId=" + docId;

            SetActionButtonStatus((DocumentStatus)doc.Status);
        }
Ejemplo n.º 4
0
        public bool UpdateDocumentInfo(DriverDocument obj)
        {
            bool isSaved;

            isSaved = docMgmt.Update(obj);

            return(isSaved);
        }
Ejemplo n.º 5
0
        private DriverDocument GetDriverDocument()
        {
            User           usr = GetLoggedInUser();
            DriverDocument doc = null;

            if (usr != null)
            {
                doc = userService.GetDocumentByUserId(usr.Id);
            }
            return(doc);
        }
Ejemplo n.º 6
0
        private void SaveDocumentImage(Button sender)
        {
            Stream       fs = null;
            BinaryReader br = null;

            byte[]         bytes = null;
            DriverDocument doc   = GetDriverDocument();

            if (doc == null)
            {
                throw new ArgumentNullException("DriverDocument");
            }
            DocumentType docType = DocumentType.VehicleImage1;

            if (sender.ID == btnUploadVehPic1.ID)
            {
                fs      = filUploadVehPic1.PostedFile.InputStream;
                docType = DocumentType.VehicleImage1;
            }
            else if (sender.ID == btnUploadVehPic2.ID)
            {
                fs      = filUploadVehPic2.PostedFile.InputStream;
                docType = DocumentType.VehicleImage2;
            }
            else if (sender.ID == btnUploadLicenseCopy.ID)
            {
                fs      = filUploadLicPic.PostedFile.InputStream;
                docType = DocumentType.LicenseImage;
            }
            br    = new BinaryReader(fs);
            bytes = br.ReadBytes((Int32)fs.Length);
            if (userService.SaveDocumentImage(doc.Id, bytes, docType))
            {
                lblMessage.Text = "Image uploaded successfully";
            }

            //if all the document/images have been uploaded send the email
            if (doc.VehiclePicture1 != null && doc.VehiclePicture2 != null && doc.LicensePicture != null)
            {
                User usr = GetLoggedInUser();
                CommonUtils.SendEmail(EmailTemplate.DocumentsReceived, usr.Email, usr.Firstname, usr.Lastname);
            }
        }
Ejemplo n.º 7
0
        protected void grdDriverDocuments_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DriverDocument doc = ((DriverDocument)e.Row.DataItem);

                long  documentId = doc.Id;
                Image imgVehImg1 = e.Row.FindControl("imgVehImg1") as Image;
                imgVehImg1.ImageUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document) + "type=" + DocumentType.VehicleImage1.ToString() + "&docId=" + documentId;

                Image imgVehImg2 = e.Row.FindControl("imgVehImg2") as Image;
                imgVehImg2.ImageUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document) + "type=" + DocumentType.VehicleImage2.ToString() + "&docId=" + documentId;

                Image imgVehImg3 = e.Row.FindControl("imgVehImg3") as Image;
                imgVehImg3.ImageUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document) + "type=" + DocumentType.LicenseImage.ToString() + "&docId=" + documentId;

                Label lblStatus = e.Row.FindControl("lblDocumentStatus") as Label;
                lblStatus.Text = GetDocumentStatus(doc.Status);
            }
        }
Ejemplo n.º 8
0
        private void LoadDriverDocuments()
        {
            DriverDocument doc = GetDriverDocument();

            if (doc == null)
            {
                pnlDriverDocuments.Enabled = false;
            }
            else
            {
                txtSSN.Text           = doc.SSN;
                txtLicenseNumber.Text = doc.LicenseNumber;
                txtVehicleNumber.Text = doc.VehicleNumber;
                string imageHandlerUrl = PageKeys.GetImageHandlerUrl(PageKeys.ImageHandlerActions.Document);
                imgPreviewVehPic1.ImageUrl = imageHandlerUrl + "type=" + DocumentType.VehicleImage1.ToString() + "&docId=" + doc.Id;
                imgPreviewVehPic2.ImageUrl = imageHandlerUrl + "type=" + DocumentType.VehicleImage2.ToString() + "&docId=" + doc.Id;
                imgPreviewLicense.ImageUrl = imageHandlerUrl + "type=" + DocumentType.LicenseImage.ToString() + "&docId=" + doc.Id;


                pnlDriverDocuments.Enabled = true;
            }
        }
Ejemplo n.º 9
0
        private bool SaveDocument(string authenticationToken, byte[] documentData, DocumentType docType)
        {
            var user = GetUserByToken(authenticationToken);
            if (user == null)
                throw new Exception("No user found with the token provided");

            if (user.UserType != (short)UserType.Driver)
                throw new Exception("The requested user is not a driver.");

            DriverDocument doc = svc.GetDocumentByUserId(user.Id);
            if (doc == null)
                throw new Exception("No basic document info was found for the user");
            bool isDocumentSaved = false;
            isDocumentSaved = svc.SaveDocumentImage(doc.Id, documentData, docType);

            if(doc.VehiclePicture1!=null && doc.VehiclePicture2!=null && doc.LicensePicture!=null) //if all required documents have been uploaded
            {
                //Send information email to driver about document receiption confirmation
                CommonUtils.SendEmail(EmailTemplate.DocumentsReceived, user.Email, user.Firstname, user.Lastname);
            }
            return isDocumentSaved;
        }
Ejemplo n.º 10
0
        public bool SaveDocumentImage(long id, byte[] imageData, DocumentType docType)
        {
            DriverDocument doc = docMgmt.GetById(id);

            switch (docType)
            {
            case DocumentType.VehicleImage1:
                doc.VehiclePicture1 = imageData;
                break;

            case DocumentType.VehicleImage2:
                doc.VehiclePicture2 = imageData;
                break;

            case DocumentType.LicenseImage:
                doc.LicensePicture = imageData;
                break;

            default:
                break;
            }
            return(docMgmt.Update(doc));
        }
Ejemplo n.º 11
0
        private void SaveDocumentInfo()
        {
            DriverDocument doc = GetDriverDocument();

            if (doc == null)
            {
                doc               = new DriverDocument();
                doc.UserId        = GetLoggedInUser().Id;
                doc.LicenseNumber = txtLicenseNumber.Text;
                doc.SSN           = txtSSN.Text;
                doc.VehicleNumber = txtVehicleNumber.Text;
                doc.Status        = (short)DocumentStatus.Pending;
                userService.InsertDocumentInfo(doc);
            }
            else
            {
                doc.LicenseNumber = txtLicenseNumber.Text;
                doc.SSN           = txtSSN.Text;
                doc.VehicleNumber = txtVehicleNumber.Text;
                userService.UpdateDocumentInfo(doc);
            }
            lblMessage.Text = "Document information saved successfully.";
        }
Ejemplo n.º 12
0
        public byte[] GetDocumentImage(DocumentType type, long documentId)
        {
            DriverDocument doc = docMgmt.GetById(documentId);

            byte[] bytes = null;
            switch (type)
            {
            case DocumentType.VehicleImage1:
                bytes = doc.VehiclePicture1;
                break;

            case DocumentType.VehicleImage2:
                bytes = doc.VehiclePicture2;
                break;

            case DocumentType.LicenseImage:
                bytes = doc.LicensePicture;
                break;

            default:
                break;
            }
            return(bytes);
        }
Ejemplo n.º 13
0
        public DriverDocumentResponse GetDriverDocument(string authenticationToken)
        {
            var user = GetUserByToken(authenticationToken);
            if (user == null)
                throw new Exception("user not found for authentication token provided");

            if (user.UserType != (short)UserType.Driver)
                throw new Exception("user found is not a driver.");

            DriverDocument doc = user.DriverDocuments.SingleOrDefault();

            if (doc != null)
            {
                return new DriverDocumentResponse()
                {
                    SSN = doc.SSN,
                    LicenseImage = doc.LicensePicture,
                    LicenseNumber = doc.LicenseNumber,
                    VehicleImage1 = doc.VehiclePicture1,
                    VehicleImage2 = doc.VehiclePicture2
                };
            }
            return null;
        }
Ejemplo n.º 14
0
 public bool InsertDocumentInfo(DriverDocument obj)
 {
     return(docMgmt.Add(obj));
 }