public IHttpActionResult PostComapnyInfo(MVCCompanyInfoModel MVCcomapnyInfo) { try { ComapnyInfo comapnyInfo = new ComapnyInfo(); comapnyInfo.CompanyName = MVCcomapnyInfo.CompanyName; comapnyInfo.CompanyLogo = MVCcomapnyInfo.CompanyLogo; comapnyInfo.CompanyAddress = MVCcomapnyInfo.CompanyAddress; comapnyInfo.StreetNumber = MVCcomapnyInfo.StreetNumber; comapnyInfo.PostalCode = MVCcomapnyInfo.PostalCode; comapnyInfo.CompanyCity = MVCcomapnyInfo.CompanyCity; comapnyInfo.CompanyCountry = MVCcomapnyInfo.CompanyCountry; comapnyInfo.CompanyPhone = MVCcomapnyInfo.CompanyPhone; comapnyInfo.CompanyCell = MVCcomapnyInfo.CompanyCell; comapnyInfo.CompanyEmail = MVCcomapnyInfo.CompanyEmail; comapnyInfo.Website = MVCcomapnyInfo.Website; comapnyInfo.BankName = MVCcomapnyInfo.BankName; comapnyInfo.IBANNumber = MVCcomapnyInfo.IBANNumber; comapnyInfo.BIC = MVCcomapnyInfo.BIC; comapnyInfo.KVK = MVCcomapnyInfo.KVK; comapnyInfo.BTW = MVCcomapnyInfo.BTW; comapnyInfo.UserName = MVCcomapnyInfo.UserName; db.ComapnyInfoes.Add(comapnyInfo); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = comapnyInfo.CompanyID }, comapnyInfo)); } catch (Exception ex) { return(BadRequest()); } }
public ActionResult Edit() { int id = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + id.ToString()).Result; MVCCompanyInfoModel CompanyInfo = response.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; return(View(CompanyInfo)); }
public ActionResult Edit(MVCCompanyInfoModel compnayViewModel) { try { if (compnayViewModel.CompanyID > 0) { if (Request.Files.Count > 0) { string fname; HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/"; //string filename = Path.GetFileName(Request.Files[i].FileName); HttpPostedFileBase file = files[i]; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { string filename = Path.GetFileNameWithoutExtension(file.FileName); string Extention = Path.GetExtension(file.FileName); fname = file.FileName + DateTime.Now.ToString("yymmssfff") + Extention; if (Extention != "") { compnayViewModel.CompanyLogo = fname; } } // Get the complete folder path and store the file inside it. fname = Path.Combine(Server.MapPath("/images/"), fname); file.SaveAs(fname); } } } compnayViewModel.UserName = "******"; HttpResponseMessage response = GlobalVeriables.WebApiClient.PutAsJsonAsync("APIComapny/" + compnayViewModel.CompanyID, compnayViewModel).Result; MVCCompanyInfoModel CompanyModel = response.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; } catch (Exception ex) { return(null); } return(View(compnayViewModel)); }
public ActionResult Edit(int Id = 0) { int CompanyId = 0; ExpenseViewModel experviewModel = new ExpenseViewModel(); try { ViewBag.FILE = CreatDirectoryClass.GetFileDirectiory(Id, "Expense"); if (Session["CompayID"] != null) { CompanyId = Convert.ToInt32(Session["CompayID"]); } ViewBag.VatDrop = GetVatList(); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; CommonModel commonModel = new CommonModel(); commonModel.Name = "Expense"; ViewBag.commonModel = commonModel; ViewBag.Companydata = companyModel; HttpResponseMessage Expense = GlobalVeriables.WebApiClient.GetAsync("GetExpenseById/" + Id).Result; experviewModel = Expense.Content.ReadAsAsync <ExpenseViewModel>().Result; HttpResponseMessage expenseDetail = GlobalVeriables.WebApiClient.GetAsync("GetExpenseDetailById/" + Id).Result; List <ExpenseViewModel> ExpenseDetailList = expenseDetail.Content.ReadAsAsync <List <ExpenseViewModel> >().Result; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetExpense/" + CompanyId).Result; List <MVCAccountTableModel> AccountmodelObj = response.Content.ReadAsAsync <List <MVCAccountTableModel> >().Result; ViewBag.Accounts = AccountmodelObj; ViewBag.ExpenseDetail = ExpenseDetailList; ViewBag.AccountId = experviewModel.ACCOUNT_ID; ViewBag.Ref = experviewModel.REFERENCEno; ViewBag.Date = experviewModel.AddedDate; ViewBag.VenderId = experviewModel.VENDOR_ID; } catch (Exception) { throw; } if (Session["CompayID"] != null) { CompanyId = Convert.ToInt32(Session["CompayID"]); } return(View(experviewModel)); }
public ActionResult PrintJournal(DateTime?FromDate, DateTime?Todate) { try { var idd = Session["ClientID"]; var cdd = Session["CompayID"]; if (Session["CompayID"] != null) { CompanyID = Convert.ToInt32(Session["CompayID"]); } else { return(RedirectToAction("Index", "Login")); } long FromDa = Convert.ToDateTime(FromDate).Ticks; long TDate = Convert.ToDateTime(Todate).Ticks; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetJournal/" + FromDa + "/" + TDate).Result; ViewBag.JournalList = response.Content.ReadAsAsync <List <TransactionModel> >().Result; if (TempData["Compantinfo"] == null) { CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; _company = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; TempData["Compantinfo"] = _company; TempData.Keep(); } string PdfName = "journal" + "-" + FromDate + "-" + Todate + ".pdf"; return(new Rotativa.PartialViewAsPdf("~/Views/Reports/JournalPartialView.cshtml") { PageSize = Rotativa.Options.Size.A4, MinimumFontSize = 16, FileName = PdfName, PageHeight = 40, PageMargins = new Rotativa.Options.Margins(10, 12, 20, 3) }); } catch (Exception) { throw; } return(View()); }
public ActionResult Journal() { long lFromDate, lTDate = 0; if (Session["CompayID"] != null) { CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; _company = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; TempData["Compantinfo"] = _company; TempData.Keep(); } if (TempData["FromDate"] != null) { _SearchModel.FromDate = (DateTime)TempData["FromDate"]; TempData["FromDate"] = null; } else { _SearchModel.FromDate = DateTime.Now; } if (TempData["ToDate"] != null) { _SearchModel.Todate = (DateTime)TempData["Todate"]; TempData["ToDate"] = null; } else { _SearchModel.Todate = DateTime.Now; } lFromDate = _SearchModel.FromDate.Ticks; lTDate = _SearchModel.Todate.Ticks; try { HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetJournal/" + lFromDate + "/" + lTDate).Result; _SearchModel._TransactionList = response.Content.ReadAsAsync <List <TransactionModel> >().Result; return(View(_SearchModel)); } catch (Exception) { throw; } return(View()); }
public IHttpActionResult GetComapnyInfo(int id) { try { MVCCompanyInfoModel comapnyInfo = db.ComapnyInfoes.Where(x => x.CompanyID == id).Select(c => new MVCCompanyInfoModel { CompanyID = c.CompanyID, CompanyName = c.CompanyName, CompanyAddress = c.CompanyAddress, CompanyPhone = c.CompanyPhone, CompanyCell = c.CompanyCell, CompanyEmail = c.CompanyEmail, CompanyLogo = c.CompanyLogo, CompanyCity = c.CompanyCity, CompanyCountry = c.CompanyCountry, AddedBy = c.AddedBy, AddedDate = c.AddedDate, UserName = c.UserName, StreetNumber = c.StreetNumber, PostalCode = c.PostalCode, Website = c.Website, BankName = c.BankName, IBANNumber = c.IBANNumber, BIC = c.BIC, KVK = c.KVK, BTW = c.BTW }).FirstOrDefault(); if (comapnyInfo != null) { Request.Content.Headers.Add("CompayID", comapnyInfo.CompanyID.ToString()); Request.Headers.Add("CompayID", comapnyInfo.CompanyID.ToString()); return(Ok(comapnyInfo)); } else { return(null); } } catch (Exception) { return(null); } }
public ActionResult GetCompanyInfo(string ID) { MVCCompanyInfoModel cominfo = new MVCCompanyInfoModel(); if (ID != null) { Session["CompayID"] = ID; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + ID.ToString()).Result; cominfo = response.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; Session["CompanyName"] = cominfo.CompanyName; Session["CompanyEmail"] = cominfo.CompanyEmail; Session["CompanyContact"] = cominfo.CompanyPhone; return(Json(cominfo, JsonRequestBehavior.AllowGet)); } else { return(Json(cominfo)); } }
public ActionResult Add() { int CompanyId = 0; try { if (Session["CompayID"] != null) { CompanyId = Convert.ToInt32(Session["CompayID"]); } HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; CommonModel commonModel = new CommonModel(); commonModel.Name = "Expense"; ViewBag.commonModel = commonModel; ViewBag.Companydata = companyModel; } catch (Exception) { throw; } return(View()); }
public ActionResult Index() { HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + 53.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("ApiConatacts/" + 64.ToString()).Result; MVCContactModel contectmodel = response.Content.ReadAsAsync <MVCContactModel>().Result; CommonModel commonModel = new CommonModel(); commonModel.Name = "Invoice"; commonModel.ReferenceNumber = "1221"; commonModel.FromDate = System.DateTime.Now; commonModel.DueDate = System.DateTime.Now; commonModel.Number_Id = "1110001"; ViewBag.Contentdata = contectmodel; ViewBag.Companydata = companyModel; ViewBag.commonModel = commonModel; return(View()); }
public string SaveOnPathe(string ReportName, DateTime FromDate, DateTime Todate) { TempData["FromDate"] = FromDate; TempData["ToDate"] = Todate; string pdfname = ""; try { CompanyID = Convert.ToInt32(Session["CompayID"]); long FromDa = Convert.ToDateTime(FromDate).Ticks; long TDate = Convert.ToDateTime(Todate).Ticks; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetJournal/" + FromDa + "/" + TDate).Result; ViewBag.JournalList = response.Content.ReadAsAsync <List <TransactionModel> >().Result; CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; _company = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; TempData["Compantinfo"] = _company; TempData.Keep(); string companyName = ReportName + "-" + FromDate + "-" + Todate + ".pdf"; var root = Server.MapPath("/PDF/"); var path = Path.Combine(root, companyName); pdfname = path; string subPath = "/PDF"; bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } if (System.IO.File.Exists(path)) { try { if (System.IO.File.Exists(path)) { FileInfo info = new FileInfo(path); pdfname = path; if (!IsFileLocked(info)) { info.Delete(); } } } catch (System.IO.IOException) { } } var pdfResult = new Rotativa.PartialViewAsPdf("~/Views/Reports/JournalPartialView.cshtml") { PageSize = Rotativa.Options.Size.A4, MinimumFontSize = 16, PageMargins = new Rotativa.Options.Margins(10, 12, 20, 3), PageHeight = 40, SaveOnServerPath = path, }; pdfResult.BuildPdf(this.ControllerContext); } catch (Exception EX) { throw EX; } return(pdfname); }
public ActionResult Journal(SearchModel _searchModel) { SearchModel _model = new SearchModel(); try { if (_searchModel.FromDate > _searchModel.Todate) { ViewBag.massage = "From Date must be Less from To Date"; if (TempData["Compantinfo"] == null) { CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; _company = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; TempData["Compantinfo"] = _company; TempData.Keep(); } _model.FromDate = _searchModel.FromDate; _model.Todate = _searchModel.Todate; return(View(_model)); } else { FormCollection form; if (Request.Form["SendEmail"] != null) { string Path = SaveOnPathe("Journal", _searchModel.FromDate, _searchModel.Todate); TempData["Pathe"] = Path; TempData.Keep(); return(RedirectToAction("ReportByEmail")); } long FromDate = Convert.ToDateTime(_searchModel.FromDate).Ticks; long TDate = Convert.ToDateTime(_searchModel.Todate).Ticks; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetJournal/" + FromDate + "/" + TDate).Result; _model._TransactionList = response.Content.ReadAsAsync <List <TransactionModel> >().Result; if (TempData["Compantinfo"] == null) { CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; _company = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; TempData["Compantinfo"] = _company; TempData.Keep(); } } } catch (Exception EX) { throw EX; } _model.FromDate = _searchModel.FromDate; _model.Todate = _searchModel.Todate; return(View(_model)); }
public ActionResult AddOrEdit(MVCCompanyInfoModel compnayViewModel) { var se = Session["username"].ToString(); if (Session["username"].ToString() != null) { compnayViewModel.UserName = Session["username"].ToString(); if (Request.Files.Count > 0) { #region try { // Get all files from Request object HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { string fname; //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/"; //string filename = Path.GetFileName(Request.Files[i].FileName); HttpPostedFileBase file = files[i]; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { string filename = Path.GetFileNameWithoutExtension(file.FileName); string Extention = Path.GetExtension(file.FileName); fname = file.FileName + DateTime.Now.ToString("yymmssfff") + Extention; compnayViewModel.CompanyLogo = fname; } var path = Server.MapPath("/images/"); try { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } // Get the complete folder path and store the file inside it. fname = Path.Combine(Server.MapPath("/images/"), fname); file.SaveAs(fname); } catch (Exception) { throw; } } // Returns message that successfully uploaded if (compnayViewModel.CompanyID == null) { HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("APIComapny", compnayViewModel).Result; MVCCompanyInfoModel CompanyModel = response.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; Session["CompayID"] = CompanyModel.CompanyID; UserInfo userInfo = new UserInfo(); userInfo.username = CompanyModel.UserName.ToString(); HttpResponseMessage responses = GlobalVeriables.WebApiClient.PostAsJsonAsync("CompanyExist", userInfo).Result; if (responses.StatusCode == System.Net.HttpStatusCode.OK) { UserModel UserTbale = responses.Content.ReadAsAsync <UserModel>().Result; Session["LoginUserID"] = Convert.ToInt32(UserTbale.UserId); Session["CompayID"] = Convert.ToInt32(UserTbale.CompanyId); } return(Json(response.StatusCode, JsonRequestBehavior.AllowGet)); } else { HttpResponseMessage response = GlobalVeriables.WebApiClient.PutAsJsonAsync("APIComapny", compnayViewModel).Result; MVCCompanyInfoModel CompanyModel = response.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; return(Json(response.StatusCode, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json("Please select logo: " + ex.Message)); } #endregion } else { return(Json(se, JsonRequestBehavior.AllowGet)); } } else { return(RedirectToAction("Index", "Captcha")); } }
public JsonResult GetPendingItem(int PurchaseId) { int Contectid, CompanyID = 0; MvcPurchaseViewModel purchaseviewModel = new MvcPurchaseViewModel(); try { var idd = Session["ClientId"]; var cdd = Session["CompayID"]; if (Session["ClientId"] != null && Session["CompayID"] != null) { Contectid = Convert.ToInt32(Session["ClientId"]); CompanyID = Convert.ToInt32(Session["CompayID"]); } else { // return RedirectToAction("Index", "Login"); } GlobalVeriables.WebApiClient.DefaultRequestHeaders.Remove("CompayID"); GlobalVeriables.WebApiClient.DefaultRequestHeaders.Add("CompayID", cdd.ToString()); HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("ApiConatacts/" + idd.ToString()).Result; MVCContactModel contectmodel = response.Content.ReadAsAsync <MVCContactModel>().Result; HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + cdd.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; ViewBag.Contentdata = contectmodel; ViewBag.Companydata = companyModel; DateTime InvoiceDate = new DateTime(); InvoiceDate = DateTime.Now; purchaseviewModel.PurchaseDate = InvoiceDate; purchaseviewModel.PurchaseDueDate = InvoiceDate.AddDays(+15); HttpResponseMessage res = GlobalVeriables.WebApiClient.GetAsync("APIPurchase/" + PurchaseId.ToString()).Result; MvcPurchaseModel ob = res.Content.ReadAsAsync <MvcPurchaseModel>().Result; purchaseviewModel.PurchaseOrderID = ob.PurchaseOrderID; purchaseviewModel.Purchase_ID = ob.PurchaseID; purchaseviewModel.PurchaseDate = Convert.ToDateTime(ob.PurchaseDate); purchaseviewModel.PurchaseDueDate = (DateTime)ob.PurchaseDueDate; purchaseviewModel.PurchaseRefNumber = ob.PurchaseRefNumber; purchaseviewModel.PurchaseSubTotal = ob.PurchaseSubTotal; purchaseviewModel.PurchaseDiscountPercenteage = ob.PurchaseDiscountPercenteage; purchaseviewModel.PurchaseDiscountAmount = ob.PurchaseDiscountAmount; purchaseviewModel.PurchaseVatPercentage = ob.PurchaseVatPercentage; purchaseviewModel.PurchaseTotoalAmount = ob.PurchaseTotoalAmount; purchaseviewModel.PurchaseVenderNote = ob.PurchaseVenderNote; purchaseviewModel.Status = ob.Status; purchaseviewModel.Vat21 = (int)ob.Vat21; purchaseviewModel.Vat6 = (int)ob.Vat6; purchaseviewModel.CompanyId = ob.CompanyId; purchaseviewModel.UserId = ob.UserId; HttpResponseMessage responseQutationDetailsList = GlobalVeriables.WebApiClient.GetAsync("APIPurchaseDetail/" + PurchaseId.ToString()).Result; List <MvcPurchaseViewModel> QutationModelDetailsList = responseQutationDetailsList.Content.ReadAsAsync <List <MvcPurchaseViewModel> >().Result; ViewBag.Contentdata = contectmodel; ViewBag.Companydata = companyModel; ViewBag.PurchaseDatailsList = QutationModelDetailsList; return(new JsonResult { Data = new { PurchaseData = QutationModelDetailsList, ContectDetail = contectmodel, CompanyDta = companyModel, purchase = ob } }); } catch (Exception ex) { return(Json("", JsonRequestBehavior.AllowGet)); } return(Json("", JsonRequestBehavior.AllowGet)); }
public ActionResult PrintView(int?Id) { string pdfname; try { ExpenseViewModel experviewModel = new ExpenseViewModel(); HttpResponseMessage Expense = GlobalVeriables.WebApiClient.GetAsync("GetExpenseById/" + Id).Result; experviewModel = Expense.Content.ReadAsAsync <ExpenseViewModel>().Result; HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + experviewModel.comapny_id.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; CommonModel commonModel = new CommonModel(); commonModel.Name = "Expense"; HttpResponseMessage expenseDetail = GlobalVeriables.WebApiClient.GetAsync("GetExpenseDetailById/" + Id).Result; List <ExpenseViewModel> ExpenseDetailList = expenseDetail.Content.ReadAsAsync <List <ExpenseViewModel> >().Result; ViewBag.CompanyName = companyModel.CompanyName; ViewBag.ExpenceModel = experviewModel; ViewBag.commonModel = commonModel; ViewBag.CompanyLogo = companyModel.CompanyLogo; ViewBag.ExpenseDetail = ExpenseDetailList; string companyName = Id + "-" + companyModel.CompanyName; var root = Server.MapPath("/PDF/"); pdfname = String.Format("{0}.pdf", companyName); var path = Path.Combine(root, pdfname); path = Path.GetFullPath(path); string subPath = "/PDF"; // your code goes here bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } if (System.IO.File.Exists(path)) { try { if (System.IO.File.Exists(path)) { FileInfo info = new FileInfo(path); if (!IsFileLocked(info)) { info.Delete(); } } } catch (System.IO.IOException) { } } return(new Rotativa.PartialViewAsPdf("~/Views/Expence/ExpensePrint.cshtml") { PageSize = Rotativa.Options.Size.A4, MinimumFontSize = 16, FileName = pdfname, PageHeight = 40, PageMargins = new Rotativa.Options.Margins(10, 12, 20, 3) }); } catch (Exception) { throw; } }
public ActionResult Index(UserModels user) { HttpResponseMessage messageConformed = GlobalVeriables.WebApiClient.PostAsJsonAsync("AccountCheckStatus", user).Result; if (messageConformed.StatusCode == System.Net.HttpStatusCode.NotFound) { ViewBag.ErrorMessage = "E-mail not conformed until! Please Conform"; return(View(user)); } else { string url = GlobalVeriables.WebApiClient.BaseAddress.ToString().Replace("/api", ""); if (this.IsCaptchaValid("Captcha is not valid")) { UserInfo userInfo = new UserInfo(); userInfo.username = user.Username; userInfo.password = user.Password; userInfo.grant_type = "password"; var jsonInput = new JavaScriptSerializer().Serialize(userInfo); #region BearerToken token; using (var httpClient = new HttpClient()) { var tokenRequest = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("grant_type", "password"), new KeyValuePair <string, string>("username", userInfo.username), new KeyValuePair <string, string>("password", userInfo.password) }; HttpContent encodedRequest = new FormUrlEncodedContent(tokenRequest); //werdferf //HttpResponseMessage response = httpClient.PostAsync(url+"/Token", encodedRequest).Result; try { HttpResponseMessage response = httpClient.PostAsync(url + "Token", encodedRequest).Result; token = response.Content.ReadAsAsync <BearerToken>().Result; #region if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { ViewBag.ErrorMessage = "username or password incorrect!"; return(View(user)); } #endregion // Store token in ASP.NET Session State for later use Session["ApiAccessToken"] = token.AccessToken; } catch (Exception ex) { } } if (user.Rememberme) { HttpCookie cookie = new HttpCookie("Login"); cookie.Values.Add("UserName", user.Username); cookie.Values.Add("Password", user.Password); cookie.Values.Add("RememberMe", user.Rememberme.ToString()); cookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(cookie); } else { HttpCookie cookie = new HttpCookie("Login"); cookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie); } #endregion if (Session["ApiAccessToken"] != null) { UserModel UserTbale = new UserModel(); //HttpResponseMessage respons = GlobalVeriables.WebApiClient.GetAsync("/api/GetCompanyID" + "test").Result; string name = userInfo.username.ToString(); Session["username"] = name; GlobalVeriables.WebApiClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Session["ApiAccessToken"].ToString()); HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("CompanyExist", userInfo).Result; int compnyID = 0; if (response.StatusCode == System.Net.HttpStatusCode.OK) { UserTbale = response.Content.ReadAsAsync <UserModel>().Result; Session["LoginUserID"] = Convert.ToInt32(UserTbale.UserId); compnyID = Convert.ToInt32(UserTbale.CompanyId); } #region if (response.StatusCode == System.Net.HttpStatusCode.OK) { MVCCompanyInfoModel cominfo = new MVCCompanyInfoModel(); Session["CompayID"] = compnyID; HttpResponseMessage responses = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + compnyID.ToString()).Result; cominfo = responses.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; Session["CompanyName"] = cominfo.CompanyName; Session["CompanyEmail"] = cominfo.CompanyEmail; Session["CompanyContact"] = cominfo.CompanyPhone; Session["username"].ToString(); HttpResponseMessage responseUser = GlobalVeriables.WebApiClient.PostAsJsonAsync("GetUserInfo", userInfo).Result; UserModel usermodel = responseUser.Content.ReadAsAsync <UserModel>().Result; return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("NewCompany")); } #endregion } } ViewBag.ErrorMessage = "captcha is not valid upto now."; return(View(user)); } }
public string PrintViewsdwede(int?Id) { string pdfname; try { ExpenseViewModel experviewModel = new ExpenseViewModel(); HttpResponseMessage Expense = GlobalVeriables.WebApiClient.GetAsync("GetExpenseById/" + Id).Result; experviewModel = Expense.Content.ReadAsAsync <ExpenseViewModel>().Result; HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + experviewModel.comapny_id.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; CommonModel commonModel = new CommonModel(); commonModel.Name = "Expense"; HttpResponseMessage expenseDetail = GlobalVeriables.WebApiClient.GetAsync("GetExpenseDetailById/" + Id).Result; List <ExpenseViewModel> ExpenseDetailList = expenseDetail.Content.ReadAsAsync <List <ExpenseViewModel> >().Result; ViewBag.CompanyName = companyModel.CompanyName; ViewBag.ExpenceModel = experviewModel; ViewBag.commonModel = commonModel; ViewBag.CompanyLogo = companyModel.CompanyLogo; ViewBag.ExpenseDetail = ExpenseDetailList; string companyName = Id + "-" + companyModel.CompanyName; var root = Server.MapPath("/PDF/"); pdfname = String.Format("{0}.pdf", companyName); var path = Path.Combine(root, pdfname); path = Path.GetFullPath(path); string subPath = "/PDF"; // your code goes here bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } if (System.IO.File.Exists(path)) { try { if (System.IO.File.Exists(path)) { FileInfo info = new FileInfo(path); if (!IsFileLocked(info)) { info.Delete(); } } } catch (System.IO.IOException) { } } var pdfResult = new Rotativa.PartialViewAsPdf("~/Views/Expence/ExpensePrint.cshtml") { PageSize = Rotativa.Options.Size.A4, MinimumFontSize = 16, PageMargins = new Rotativa.Options.Margins(10, 12, 20, 3), PageHeight = 40, SaveOnServerPath = path, // Save your place // CustomSwitches = "--footer-center \"" + "Wilt u zo vriendelijk zijn om het verschuldigde bedrag binnen " + diffDate + " dagen over te maken naar IBAN: " + companyModel.IBANNumber + " ten name van IT Molen o.v.v.bovenstaande factuurnummer. (Op al onze diensten en producten zijn onze algemene voorwaarden van toepassing.Deze kunt u downloaden van onze website.)" + " Printed date: " + // DateTime.Now.Date.ToString("MM/dd/yyyy") + " Page: [page]/[toPage]\"" + //" --footer-line --footer-font-size \"10\" --footer-spacing 6 --footer-font-name \"calibri light\"", }; pdfResult.BuildPdf(this.ControllerContext); } catch (Exception) { throw; } return(pdfname); }