コード例 #1
0
        public JsonResult CreateEntry([FromBody] WarrantyClaimModel data)
        {
            string retval = "ok";

            if (!ProductIdValidationController.ValidateProductId(data.SerialNumber))
            {
                retval = "Invalid ProductId";
                return(new JsonResult(new { result = retval }));
            }


            string details =
                System.IO.File.ReadAllText(@"D:\home\site\wwwroot\" + "private.p12");


            using (MemoryStream receiptimage = ConvertFromBase64(data.ReceiptImageString))
                using (MemoryStream serialnumberimage = ConvertFromBase64(data.SerialNumberImageString))
                {
                    //saving data in google drive.
                    try
                    {
                        DriveApiService service = new DriveApiService();

                        string receiptfilename = "Receipt"
                                                 + "-" + data.SerialNumber
                                                 + "-" + data.LastName
                                                 + "-" + data.EmailAddress
                                                 + "-" + data.ReceiptFileName;

                        string serialnumberfilename = "SerialNumber"
                                                      + "-" + data.SerialNumber
                                                      + "-" + data.LastName
                                                      + "-" + data.EmailAddress
                                                      + "-" + data.ReceiptFileName;

                        string receipturllink =
                            service.UploadWarrantyClaimDocument(receiptimage,
                                                                receiptfilename);

                        string serialnumlink =
                            service.UploadWarrantyClaimDocument(serialnumberimage,
                                                                serialnumberfilename);


                        service.UpdateWarrantyClaimSheet(data.SerialNumber,
                                                         data.PurchaseDate,
                                                         data.FirstName,
                                                         data.LastName,
                                                         data.DateofBirth,
                                                         data.EmailAddress,
                                                         data.AddressLine1,
                                                         data.AddressLine2,
                                                         data.City,
                                                         data.State,
                                                         data.ZipCode,
                                                         data.Country,
                                                         data.ClaimReason,
                                                         receipturllink,
                                                         serialnumlink,
                                                         DateTime.Now.ToShortDateString());

                        //"*****@*****.**"
                        string ownerwarrantyemailbodystring =
                            GetOwnerWarrantyEmailBodyString(data, receipturllink, serialnumlink);
                        string customerwarrantyemailbodystring =
                            GetCustomerWarrantyEmailBodyString(data, receipturllink, serialnumlink);

                        AttachmentItem itemreceipt      = PackageImage(receiptimage, receiptfilename);
                        AttachmentItem itemserialnumber = PackageImage(serialnumberimage, serialnumberfilename);

                        List <AttachmentItem> items = new List <AttachmentItem>();
                        items.Add(itemreceipt);
                        items.Add(itemserialnumber);

                        List <string> owneremails = new List <string>();

                        owneremails.Add("*****@*****.**");

                        List <string> receipientemails = new List <string>();

                        receipientemails.Add(data.EmailAddress);

                        service.SendEmail(ownerwarrantyemailbodystring,
                                          "Warranty Claim Received",
                                          owneremails,
                                          items);
                        service.SendEmail(customerwarrantyemailbodystring,
                                          "Warranty Claim Received",
                                          receipientemails,
                                          new List <AttachmentItem>());
                    }

                    catch (Exception ex)
                    {
                        retval = "Error";
                    }
                }

            return(new JsonResult(new { result = retval }));
        }
コード例 #2
0
        public JsonResult CreateEntry([FromBody] RegistrationModel data)
        {
            string retval = "ok";

            if (!ProductIdValidationController.ValidateProductId(data.SerialNumber))
            {
                retval = "Invalid ProductId";
                return(new JsonResult(new { result = retval }));
            }


            string details =
                System.IO.File.ReadAllText(@"D:\home\site\wwwroot\" + "private.p12");

            MemoryStream image = ConvertFromBase64(data.ImageString);

            //saving data in google drive.
            //try
            //{
            DriveApiService service = new DriveApiService();

            string filename1 = data.SerialNumber
                               + "-" + data.LastName
                               + "-" + data.EmailAddress
                               + "-" + data.FileName;

            string urllink =
                service.UploadRegistrationDocument(image,
                                                   filename1);

            service.UpdateRegistrationSheet(data.SerialNumber,
                                            data.PurchaseDate,
                                            data.FirstName,
                                            data.LastName,
                                            data.DateofBirth,
                                            data.EmailAddress,
                                            data.AddressLine1,
                                            data.AddressLine2,
                                            data.City,
                                            data.State,
                                            data.ZipCode,
                                            data.Country,
                                            urllink,
                                            DateTime.Now.ToShortDateString());

            //"*****@*****.**"
            string ownerregistrationemailbodystring =
                GetOwnerRegistrationEmailBodyString(data, urllink);
            string customerregistrationemailbodystring =
                GetCustomerRegistrationEmailBodyString(data, urllink);

            AttachmentItem item = PackageImage(image, data);

            List <AttachmentItem> items = new List <AttachmentItem>();

            items.Add(item);

            List <string> owneremails = new List <string>();

            owneremails.Add("*****@*****.**");

            List <string> receipientemails = new List <string>();

            receipientemails.Add(data.EmailAddress);

            service.SendEmail(ownerregistrationemailbodystring,
                              "Registration Received",
                              owneremails,
                              items);
            service.SendEmail(customerregistrationemailbodystring,
                              "Registration Received",
                              receipientemails,
                              new List <AttachmentItem>());

            //}

            // catch(Exception ex)
            // {
            //     retval = "Error";
            // }



            return(new JsonResult(new { result = retval }));;
        }