This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // get the uploaded file from the request | |
| var uploadedFile = base.Request.Files[0]; | |
| // create directory if it doesn't exist | |
| if (!Directory.Exists(Server.MapPath("~/Catalogues/Products"))) | |
| Directory.CreateDirectory(Server.MapPath("~/Catalogues/Products")); | |
| // get the path where the uploaded csv will be saved | |
| var path = Server.MapPath(String.Format("~/Catalogues/Products/{1}", | |
| "products.csv")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //create the "database" connection string | |
| string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" | |
| + "Data Source=\"" + dir + "\\\";" | |
| + "Extended Properties=\"text;HDR=Yes;FMT=Delimited\""; | |
| //create the database query | |
| string query = "SELECT * FROM " + file; | |
| //create a DataTable to hold the query results | |
| DataTable dTable = new DataTable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var productDtos = new List<ProductDto>(); | |
| try { | |
| foreach (DataRow dr in dTable.Rows) | |
| { | |
| productDtos.Add(new ProductDto() | |
| { | |
| description = dr["Description"].ToString(), | |
| name = dr["Name"].ToString(), | |
| pageNumber = int.Parse(dr["PageNumber"].ToString()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "name","description","price","thumbUrl","pageNumber" | |
| "Product A","This is product A","1.00","http://someurl.com/producta.jpg","1" | |
| "Product B","This is product B","1.00","http://someurl.com/productb.jpg","2" | |
| "Product C","This is product C","4.00","http://someurl.com/productc.jpg","3" | |
| "Product D","This is product D","2.00","http://someurl.com/productd.jpg","4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MvcApplication : TurbineApplication | |
| { | |
| public MvcApplication() | |
| { | |
| ServiceLocatorManager.SetLocatorProvider(() => new StructureMapServiceLocator()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace VoucherPrototype.Routing | |
| { | |
| public class DefaultRouting : IRouteRegistrator | |
| { | |
| public void Register(RouteCollection routes) | |
| { | |
| routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
| routes.MapRoute( | |
| "Default", // Route name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace VoucherPrototype.Registration | |
| { | |
| public class DefaultRegistration : IServiceRegistration | |
| { | |
| public void Register(IServiceLocator locator) | |
| { | |
| locator.Register<IVoucherRepository, VoucherRepository>(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class VouchersController : Controller | |
| { | |
| private IVoucherRepository _voucherRepository; | |
| public VouchersController(IVoucherRepository voucherRepository) | |
| { | |
| _voucherRepository = voucherRepository; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul> | |
| @foreach (var deal in Model) | |
| { | |
| <li>@deal.Description</li> | |
| } | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ul { | |
| list-style-type: none; | |
| padding: 0; | |
| } |
OlderNewer