public override string[] GetRolesForUser(string username) { ProductManagementDbEntities db = new ProductManagementDbEntities(); var kullanici = db.Kullanici.FirstOrDefault(x => x.Ad == username); return(new string[] { kullanici.Role }); }
public ActionResult Edit(int id) { ProductRepository productRepository = new ProductRepository(); var product = productRepository.GetProductById(id); ProductManagementDbEntities _db = new ProductManagementDbEntities(); ViewBag.ownerList = (from owner in _db.Owners select new SelectListItem { Text = owner.OwnerName, Value = owner.Id.ToString() }); return(View(product)); }
public ActionResult DownloadReport() { LocalReport lr = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Views/Reports"), "ProductDetails.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { } ProductManagementDbEntities _db = new ProductManagementDbEntities(); IList <Product> products = new List <Product>(); products = _db.Products.Select(x => x).ToList(); object prods = products.Select(pr => new ProductViewModel(pr)).ToList(); ReportDataSource rd = new ReportDataSource("DataSet1", prods); lr.DataSources.Add(rd); IList <ReportParameter> reportParameters = new List <ReportParameter>() { new ReportParameter("title", "Test Report"), new ReportParameter("footer", "Generatd on" + DateTime.Now) }; lr.SetParameters(reportParameters); string mimeType; string encoding; string fileNameExtension; Warning[] warnings; string[] streams; byte[] renderedBytes; lr.Refresh(); renderedBytes = lr.Render( "PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); Response.AddHeader("Content-Disposition", "attachment; filename=Test.pdf"); return(new FileContentResult(renderedBytes, mimeType)); }
public ActionResult Create() { ProductManagementDbEntities _db = new ProductManagementDbEntities(); //ViewBag.message = "I am from viewbag"; //ViewData["msg"] = "I am from viewdata"; //ViewData["AllProducts"] = TempData["products"]; ViewBag.ownerList = (from owner in _db.Owners select new SelectListItem { Text = owner.OwnerName, Value = owner.Id.ToString() }); return(View()); }
public IList <Customer> GetAllCustomers() { ProductManagementDbEntities _db = new ProductManagementDbEntities(); return(_db.Customers.Select(x => x).ToList()); }