//[Authorize(Roles = "Admin")]
        public ActionResult GenerateInvoice(string Status, string Id, string InvoiceTo, bool CV, string InvoiceNumber, bool data = false, string UserAction = "Add")
        {
            ViewBag.Result = "Failed";
            if (data == true)
            {
                ViewBag.Result = "Succeeded";
            }

            string UserId     = User.Identity.GetUserId();
            var    UserDetail = generic.GetUserDetail(UserId);

            ViewData["UserProfile"] = UserDetail;
            ViewData["CompanyLogo"] = cmsMgr.GetCompanyLogo(UserDetail.SubscriberId).FirstOrDefault();
            var plandetail = admin.GetUserplanDetails(UserDetail.SubscriberId).Where(c => c.AddOnId == 3).FirstOrDefault();

            ViewData["plandetail"] = plandetail;
            ViewData["TaxType"]    = admin.GetTaxMaster().AsEnumerable();
            ViewData["JOItems"]    = cmsMgr.GetJobOrderItems(Id).AsEnumerable();
            ViewData["InvItems"]   = cmsMgr.GetInvoiceItems(InvoiceNumber).AsEnumerable();
            ViewData["InvTaxs"]    = admin.GetInvoiceTaxes(InvoiceNumber).AsEnumerable();

            ViewBag.InvoiceTo   = InvoiceTo;
            ViewBag.ReferenceId = Id;


            if (UserAction == "Edit")
            {
                var Invoice = admin.GetInvoiceDetails(UserId, InvoiceNumber);
                ViewBag.InvoiceDate    = Invoice.InvoiceDate;
                ViewBag.Currency       = Invoice.Currency;
                ViewBag.InvoiceNumber  = InvoiceNumber;
                ViewBag.InvoiceTo      = Invoice.InvoiceTo;
                ViewBag.ReferenceId    = Invoice.ReferenceId;
                ViewBag.AdditionalCost = Invoice.AdditionalCost;
                ViewBag.Deductions     = Invoice.Deductions;
                ViewBag.NetAmount      = Invoice.NetAmount;
                ViewData["Content"]    = (from i in db.InVoiceAttachment.Where(i => i.ReferenceId == Invoice.ReferenceId) select i).FirstOrDefault();

                return(View(Invoice));
            }
            else
            {
                var JobOrder = cmsMgr.GetJobOrderDetails(UserDetail.SubscriberId, Id, CV);
                ViewBag.InvoiceSubject = JobOrder.Subject;
                ViewBag.InvoiceDate    = DateTime.Now.Date;
                ViewBag.Currency       = JobOrder.Currency;
                ViewBag.AdditionalCost = 0;
                ViewBag.Deductions     = 0;
                ViewBag.NetAmount      = JobOrder.TotalCost;
            }


            return(View());
        }