public ActionResult DeleteFile(GoogleDriveFiles file)
 {
     GoogleDriveFilesRepository.DeleteFile(file);
     return(RedirectToAction("GetGoogleDriveFiles"));
 }
 public ActionResult DeleteFile(string id)
 {
     driveService.DeleteFile(id);
     return(RedirectToAction("GetGoogleDriveFiles"));
 }
Exemple #3
0
        public IHttpActionResult SaveInvoicePaymentDetails()
        {
            Response <InvoicepaymentDetails> output = new Response <InvoicepaymentDetails>();

            try
            {
                long?          headerUserId = null;
                HttpPostedFile Attachment   = null;
                var            re           = Request;
                var            headers      = re.Headers;
                if (headers.Contains("User"))
                {
                    string strUserId = headers.GetValues("User").First();
                    headerUserId = Convert.ToInt64(strUserId);
                }
                var httprequest = HttpContext.Current.Request;
                //var data = JObject.Parse(httprequest.Form["InvoicePaymentDetailsObject"]).ToObject<InvoicepaymentDetails>();
                InvoicepaymentDetails data = JsonConvert.DeserializeObject <InvoicepaymentDetails>(httprequest.Form["InvoicePaymentDetailsObject"]);
                //var s = JsonExtensions.FromDelimitedJson<InvoicepaymentDetails>(new StringReader(httprequest.Form["InvoicePaymentDetailsObject"])).ToList();
                if (data.PaymentTypeId != null && data.Amount != null && data.Amount > 0 && !string.IsNullOrEmpty(data.Comments) && httprequest.Files.Count > 0)
                {
                    if (httprequest.Files.Count > 0)
                    {
                        for (var i = 0; i < httprequest.Files.Count; i++)
                        {
                            Attachment = httprequest.Files[i];
                        }
                    }
                    if (data != null)
                    {
                        data.UserId = headerUserId;
                        if (invoiceMethods.UpdateInvoicePaymentDetails(data.InvoiceId, data.PaymentTypeId, data.Amount, data.Comments, data.UserId, data, Attachment) > 0)
                        {
                            string InvoiceFileId = invoiceMethods.GetInvoiceDetails(data.InvoiceId).InvoiceFileId;
                            GoogleDriveFilesRepository.DeleteFile(InvoiceFileId);
                            GenerateInvoicePDF(data.vc_invoice_number, data.vc_invoice_date, data.InvoiceId, headerUserId);
                            output.Message = "Invoice payment details saved successfully";
                            output.Status  = true;
                        }
                        else
                        {
                            output.Message = "Something went wrong";
                            output.Status  = false;
                        }
                    }
                    else
                    {
                        output.Message = "Invalid data";
                        output.Status  = false;
                    }
                }
                else
                {
                    output.Message = data.PaymentTypeId != null? (data.Amount != null && data.PaymentTypeId > 0)? httprequest.Files.Count > 0 ? "Please enter comments" : "Please select file" : "Please enter amount" : "Please select payment type";
                    output.Status  = false;
                }
                return(Ok(JObject.FromObject(output)));
            }
            catch (Exception ex)
            {
                output.Status  = false;
                output.Message = ex.Message;
                return(InternalServerError(ex));
            }
        }
 public ActionResult DeleteFile(GoogleDriveFile file)
 {
     GoogleDriveFilesRepository.DeleteFile(file);
     return(RedirectToAction("Certificados"));
 }