archive-dk.com » DK » N » NDESOFT.DK

Total: 240

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • NDesoft - ... just me writing...
    contain all information needed by the view and not contain any logic A view should only present the model It should not do more than that A controller should create and package a model with the data needed by the consumer In most cases the view So with this in mind we looked at how we used to do umbraco sites both pre MVC and with MVC and we saw that we where actually not doing anything by the book All of our views contained a mix of presentation markup and data access logic In my line of work we often come across working with frontenders These are developers working solely with markup and client side scripting and most knows nothing about NET C or even the Umbraco API There are many ways to help these poor frontenders as this excellent post The right amount of separation of concerns in Umbraco Razor describes we can help a lot by separating our logic from our presentation without making a big deal out of it The only problem I see is that it still makes the frontenders able to mess with our code In my point of view the frontenders don t need to know where the data comes from or how it gets there When the open a view the only thing they should see is markup and a minimum amount of server side code and this is what MVC allows us to give to the frontenders It also allows us to be the developers and not think about any of the views We only serve a model to our frontenders so they can use it to create an awesome site without thinking much about C API s or whatever Prerequisites So lets get started with our umbraco MVC app First off we need to setup our solution with anything we need Open Visual Studio and create an empty MVC application yes it must be empty Then install umbraco cms using nuget Open the config umbracosettings config and change the following line defaultRenderingEngine WebForms defaultRenderingEngine To defaultRenderingEngine MVC defaultRenderingEngine And run the application F5 install umbraco and log in to the backoffice For this example we will create two doc types MasterDocType This one should NOT have a template This doc type contains shared properties for all child doc types Create one property Shared value property That s it FrontPage This should have a template and be a child of MasterDocType Further more this doc type should be allowed at root level Create a couple of properties Properties to go on the frontpage Content Now create a node in the content section call it whatever and add some values to our properties Models Now we have our doctypes setup and we have added some content and all is good But now it s time to create our models If you have not already done so now would be a good time to stop the Visual Studio debugging session Shift F5 MasterModel I always suffix all my models with Model This way I can always distinguish my models from my entities or other classes Umbraco makes a great effort to tell you to make all your models derive from Umbraco Web Models RenderModel This is a BAD idea By inheriting from RenderModel we add logic to our model and allows our views to access the umbraco engine and we will have to add constructors to all of our models So I will not inherit from RenderModel I will just create a simple model like so public class MasterModel public string SharedValue get set Simple and quite readable No logic only a single property with a getter and a setter Nothin more nothin less FrontPageModel Again this is also quite simple public class FrontPageModel MasterModel public string Title get set public IHtmlString BodyText get set There are a couple of things to note here First I inherit from my MasterModel just as I inherit my FrontPage doctype from my MasterDocType Secondly my BodyText is of type IHtmlString This is because I know that the BodyText property is a string containing HTML and I would not like to clutter my views with unnecessary code like Html Raw Mappers To simplify our controllers we should create a couple of helper methods to help us map from umbraco content to our models In this example we need two mappers I ve created a folder for them called Mappers The general idea is that instead of returning IPublishedContent to our view and thus adding logic to our view we only return the values needed So for instance you will list all child nodes your model would look like this public IEnumerable MyModel Children get set Instead of public IEnumerable IPublishedContent Children get set Thus giving the frontender an opportunity to know exactly what he is working with at the moment MasterMapper This mapper has only one purpose to set the shared values of all derived models Looks something like this public static class MasterMapper public static void Map IPublishedContent content MasterModel model model SharedValue content GetPropertyValue string sharedValue FrontPageMapper This mapper is for mapping all content that is of the doctype FrontPage It could look like this public static class FrontPageMapper public static FrontPageModel Map this IPublishedContent content if content IsDocumentType FrontPage throw new ArgumentException Wrong doctype passed must be FrontPage var model new FrontPageModel Title content GetPropertyValue string title BodyText new HtmlString content GetPropertyValue string bodyText MasterMapper Map content model return model Please note I start by checking if we are trying to map the right doctype if not let the developer know he s an idiot Second note I finish up by calling my MasterMapper to set my shared value This mapper allows me to return the same data each time I want to get a frontpage Controllers Now for the fun part Creating our controllers As this is an umbraco application after all we still need to oblige to the rules of naming meaning that our controllers must be name exactly after our doctypes MasterDocTypeController All our controllers must run in UmbracoContext because of the fact that we need to be able to access umbraco content simple as that Therefore all controllers must inherit from Umbraco Web Mvc RenderMvcController No problems here So we create a doctype for our MasterDocType public class MasterDocTypeController Umbraco Web Mvc RenderMvcController In this example I don t need any logic in here but I like to have this controller just in case FrontPageController Now you probably think this controller has all the exciting code all the code that makes any of the above code seem unnecessary you are wrong In this example a very simple one I know I have not much code here public class FrontPageController MasterDocTypeController public ActionResult FrontPage RenderModel renderModel var model renderModel Content Map return View model What I do here is simply mapping my content to my model and returning it to the view If I wanted to list any child nodes it would look like so public class FrontPageController MasterDocTypeController public ActionResult FrontPage RenderModel renderModel var model renderModel Content Map model Children renderModel Content Children Where c c IsDocumentType SomeDocType Select c SomeDocTypeMapper Map c return View model This way all my childnodes are of the right type and does not contain any logic Views The final part of this post will be Views Again Umbraco goes a long way to tell us how to build our views but as I stated earlier Umbraco is NOT a Content Delivery Presentation System So it should stay out of our views Umbraco wants us to make all of our views inherit from either Umbraco Web Mvc UmbracoViewPage or Umbraco Web Mvc UmbracoTemplatePage By doing so we are actually adding logic to our views and therefore making it much harder for frontenders to build the view So instead we want to just specify the type of our model the view is build around This is done by writing model NameOfTheModelType To get started with our MVC views we have to do some ground work first Layout cshtml As any web app we must have a generic master layout file that sets up all markup used by all views I prefer naming this view Layout cshtml put it in Views Shared This layout file would in this example look like this model UmbracoMVC Models MasterModel Layout null DOCTYPE html html head meta name viewport content width device width title ViewBag Title title head body div Model SharedValue hr RenderBody div body html Note the first line of this view it states that this view is build around the MasterModel We also specify that this view has no layout viewStart cshtml If you have ever made an MVC app you ll know that any view that is not a partial view will find its master layout using the viewstart cshtml file So we will have to add this to the views folder Layout Views Shared Layout cshtml It specifies that if no other Layout is specified then any view should use the Views Shared Layout cshtml view FrontPage cshtml This view is used to deliver the actual contents of our frontpage As with the controllers we are bound by the rules of umbraco and all views must be located in the Views folder It s quite simple model UmbracoMVC Models FrontPageModel ViewBag Title Model Title h2 Model Title h2 Model BodyText As you can see there is a bare minimum amount of logic only markup and property getters Nothing more nothing less Conclusion This is a rather long post and I haven t covered nearly much on how to build a real MVC app using umbraco but I hope it gives an idea what can be done This approach might take a bit more coding but when we have done this a couple of times and made a couple of frameworks with reusable code then we can really get things done and fast We no longer have to battle with logic in our views we don t have all the string literals floating around our code to identify properties We have successfully separated views from Umbraco and thus made our views cleaner and our controller logic simpler I hope this post will spark a debate on how to develop MVC apps for umbraco in the future Please share and comment Thanks for reading Posted on May 25 2013 by Nick Frederiksen in ASP NET MVC umbraco Web Tags best practices mvc umbraco umbraco mvc web web app social news 814 http ndesoft dk 2013 05 25 how to create a real mvc app using umbraco How to create a real MVC app using umbraco 20 Why NOT to use umbraco as a data store Umbraco logo I have recently made a great fuzz on twitter by saying I don t want people to use the content section of umbraco as a data store A lot of people did not agree and then the debate began The feedback was so overwhelming neither me nor my coworkers could keep track on who what and where the debate took place So I decided to make this blog post So my initial statement is still valid No matter what you think do not use umbracos content section as a data store First off what is data and what is content Well it s a bit fuzzy but this is my definition Any information that is to be considered as metadata product information member profiles log entries values for lists and so on and so fourth is to be considered data and therefore NOT content All of that data has to be stored in a real data store Said data store would I prefer being a database And since we are using umbraco and NET why not adding a couple of extra tables in our already setup database By using your own data store you get a lot of possibilities Possibilities umbraco do not offer In your own data store you can organize your data the way your data should be organized The umbraco data store is build solely to deliver content not ecommerce not to serve as an ERP or as a CRM Umbraco is a CMS it is build to deliver content You can even cache your data as you like And why not use lucene for that It comes with umbraco and it is ridiculously fast and you can index anything you want and in any way you want The indexes and caching mechanisms used by umbraco is build to deliver content it is build to serve umbraco content not ecommerce content or ERP content only umbraco content So if you are to build an ecommerce solution or a CRM Use your own data store This way you don t force umbraco into being something it is not You make it way easier for your users to distinguish umbraco from you solution and in case of extending or rebuilding parts of your solution you don t have to force umbraco into submission you only have to change your own code So lets say you do use umbraco as a data store what problems are there Well as stated earlier you are then forcing umbraco into being something it is not you are cluttering umbraco config with non content related information and you are making an enormous content tree You are furthermore cluttering the data base we all know that any database gets slower the more data you have to out into it and by using umbraco as a data store you are adding A LOT OF DATA Lets take an example this is a bit simplified I know A customer has five properties ID Name Address city and postal code In my database one table five fields each customer one row In umbraco this translates to One doc type 1 row four properties 4 rows and one customer becomes 5 rows in two tables 1 row for the node and one row for each value and I haven t even included history information This means that the database has to handle five times the amount of data by using umbraco vs a custom table that is bad But hey Umbraco has it s XML caching and lucene to help that load Yes but the XML cache and lucene won t help much when we need to make CRUD actions in our data base I have seen very large umbraco trees and they are very heavy I have seen loading times around five minutes Not on the end user side no in the back office And yes people do use the back office Umbraco also has a very strict set of rules Umbraco is build as a tree meaning you have a parent and a lot of children I would love to see how you would handle a many to many relation like product category using umbraco In a database I would add one table with two primary keys set as foreign keys to product and category I usually use the argument of scalability A database is build to be scalable and in my opinion it is much easier to add an extra table and a couple of extra fields than it is to create an extra doc type and a couple of extra fields It is furthermore way easier to rearrange data in a database than in umbraco This is my proposal Build your own data store cache and index your data using lucene build a custom dashboard and tree for umbraco and stop forcing umbraco to do your job Umbraco is a CMS not EPR CRM or shop If you want that build it as a plugin Posted on May 11 2013 by Nick Frederiksen in umbraco Web Tags best practices cms crm data base data store database datastore ecommerce erp umbraco social news 792 http ndesoft dk 2013 05 11 why not to use umbraco as a data store Why NOT to use umbraco as a data store 7 How to make localized models in Umbraco MVC MVC it s the sh t Everything is so much easier when we use MVC So when Umbraco came out with version 5 I was super happy because I could now use my favorite framework on my favorite CMS Then Umbraco killed v5 and we had to go back to webforms and simple razors BUT then Umbraco announced they would implement MVC in the v4 branch and port many of the MVC features from v5 to v4 I was happy for a while I feared v4 would end up just like v5 Mostly because of the weird mix of MVC and webforms But no the mix was elegant and seamlessly and super fast so we began using it at my work Everything was Good UNTIL we had to make some more advanced stuff like forms Yeah some of our customers wants forms I know right So we build a couple of forms and the problems started to appear Umbraco is a Content Management System meaing it manages content One of the main forces of Umbraco is its ability to handle multiple languages And the customers know that well most of them do So our customers wanted to be able to localize all the texts on the forms This is something Umbraco cannot do not easily and definitely not pretty When I build MVC forms I usually have a view model or two public string Name get set public DateTime Birthday get set public int NumberOfKids get set This is a decent model In MVC I would build a form in one of three ways One Html EditorForModel Two div Html LabelFor m m Name div div Html EditorFor m m Name div div Html ValidationMessageFor m m Name div div Html LabelFor m m Birthday div div Html EditorFor m m Birthday div div Html ValidationMessageFor m m Birthday div

    Original URL path: http://ndesoft.dk/ (2016-04-28)
    Open archived version from archive


  • Log In - NDesoft
    umbraco Nick Frederiksen on Real MVC App using Umbraco revisited Nick Frederiksen on Why NOT to use umbraco as a data store ASP NET MVC C CSS Database Generelt Grafik Javascript jQuery Mine systemer og gadgets NMultiselect PHP Programmering umbraco Vista Web windows XHTML Archives Archives Select Month June 2014 1 March 2014 1 August 2013 1 May 2013 2 April 2013 2 January 2013 1 December 2011 1 July

    Original URL path: http://ndesoft.dk/log-in/ (2016-04-28)
    Open archived version from archive

  • About - NDesoft
    and shiver on the sight of bad written or bad structured code Even my own once in a while In 2013 I became a uCommerce MVP for my work with and my contribution to the uConnector I m a Geek with capital G love computers gadgets tv shows films games music languages and so on and so forth I hate doing things half and want to finish up before starting on a new subject I m bad at writing so please bare with me and thank you for you visit please stay tuned leave your comment cancel Comment Name Email Website C CSS HTML JavaScript Plain Text SQL XHTML XML XSLT Search this site Recent Posts Create magic with APE Umbraco and NET magic Real MVC App using Umbraco revisited How to create a real MVC app using umbraco Why NOT to use umbraco as a data store Recent Comments Nick Frederiksen on How to create a real MVC app using umbraco Lazau Florin on How to create a real MVC app using umbraco Nico on How to create a real MVC app using umbraco Nick Frederiksen on Real MVC App using Umbraco revisited Nick Frederiksen on Why NOT to

    Original URL path: http://ndesoft.dk/about/ (2016-04-28)
    Open archived version from archive

  • Contact - NDesoft
    create a real MVC app using umbraco Nico on How to create a real MVC app using umbraco Nick Frederiksen on Real MVC App using Umbraco revisited Nick Frederiksen on Why NOT to use umbraco as a data store ASP NET MVC C CSS Database Generelt Grafik Javascript jQuery Mine systemer og gadgets NMultiselect PHP Programmering umbraco Vista Web windows XHTML Archives Archives Select Month June 2014 1 March 2014

    Original URL path: http://ndesoft.dk/contact-2/ (2016-04-28)
    Open archived version from archive

  • Create magic with APE
    This template extracts all dictionary items from the database using the umbracoDbDSN connection string and generates a class containing all dictionary keys and a class for getting dictionary values using said keys The other file is Umbraco DocTypes tt It uses the same connection string to extract all document types and their properties maps the Umbraco data into C classes and properties into a class pattern like the one I described in my previous post Umbraco and NET magic The future In the future we will have an APE UCommerce package and many other APE packages You can help us making APE the best alternative to Code First on platforms not build to support Code first like Umbraco and uCommerce A long with the release of APE Umbraco we are making the whole deal open source on GitHub https github com LAITDK AwesomePropertyExtractor This is also the place to find documentation and code examples post bug reports and make pull requests It s awesome Where can I get it As this package is intended for developers it is only released through NuGet There will not be an Umbraco Package It just makes no sense to create an Umbraco package for something that needs Visual Studio to work I don t know if it works in WebMatrix To get the package look no further https www nuget org packages APE Umbraco To see examples on what APE can do take a look at the wiki https github com LAITDK AwesomePropertyExtractor wiki Hope you like the package and will help making this the goto package for any Umbraco project Posted on June 10 2014 by Nick Frederiksen in ASP NET MVC umbraco Web Tags NET APE best practices properties t4 t4 templates umbraco social news 895 http ndesoft dk 2014 06 10 create magic with ape Create magic with APE 4 Responses to Create magic with APE This package has a great potential thanks Where can I submit comments and bugs from Moran monovich moranmono June 15 2014 at 6 35 am Hi thanks Bugs and comments can be submitted on GitHub https github com LAITDK AwesomePropertyExtractor issues from Nick Frederiksen June 15 2014 at 6 41 am Sorry in advance for the newb question but how is APE different from https github com zpqrtbnk Zbu ModelsBuilder or https github com AndyButland UmbracoMapper Do they all accomplish the same thing in different ways Or am I just daft and they do completely different things I m just looking for a good approach to strongly typed view models Thanks from Dan June 16 2014 at 10 52 pm Hi sorry for the late reply your post was flagged as spam and I wasn t noticed as I was supposed to be The thing that makes APE stand out is that it doesn t force you to work differently It s in essence just an auto generated list of aliases that you can use as you like We don t map IPublishedContent to a

    Original URL path: http://ndesoft.dk/2014/06/10/create-magic-with-ape/ (2016-04-28)
    Open archived version from archive

  • Umbraco and .NET magic - NDesoft
    return the value of the property as a string But this is great for standard data types but what about other types like media pickers content pickers multiitem whatever picker We still need to learn our DocTypeProperty class how to handle those types So we add this method to the generic DocTypeProperty public virtual TValue Map IPublishedContent content return content GetPropertyValue TValue this This is the generic default mapper It handles all default umbraco data types like string DateTime int and so on Furthermore we need to update our own GetPropertyValue method return property Map content So this is all jolly but we still need to be able to get an IPublishedContent instead of just an integer with a node media id To do this we need to override the mapper public class MediaPickerProperty DocTypeProperty IPublishedContent public override IPublishedContent Map IPublishedContent content var umbracoHelper new UmbracoHelper UmbracoContext Current This should not be done each time we call this method Put it outside in a cached field return umbracoHelper TypedMedia content GetPropertyValue int this Now we can make an instance of the MediaPickerProperty var myMediaProp new MediaPickerProperty Alias someMediaPicker Again note the property name Now I have a few options The old fashioned someContent GetPropertyValue int alias returns an int someContent GetPropertyValue int myMediaProp Also returns an int and the new someContent GetPropertyValue myMediaProp Returns IPublishedContent And if I did this someContent GetPropertyValue myProp It would return string But let s say we have myProp registered as DocType string but I would like it as an IHtmlString more than just once but not as often as I want it as string I don t want to have the same property registered twice And what if I have more properties that needs to be IHtmlString once or twice Well first we need to define an IHtmlStringProperty class and create a mapper Like we did with the MediaPickerProperty The mapper however is a bit simpler just return new HtmlString content GetPropertyValue string this Now I need to be able to transform my DocTypeProperty string into my IHtmlStringProperty To do this as simple as possible we need to add a method to the base DocTypeProperty public TProp As TProp where TProp DocTypeProperty new return new TProp Alias this Alias It doesn t get any simpler than that And now you can see why I needed to have a parameterless constructor Otherwise this would have been a pain in the arse So now I can do this someContent GetPropertyValue myProp string someContent GetPropertyValue myProp As IHtmlStringProperty IHtmlString As you can see this is completely transparent You can write less code and you don t have to remember hundreds of aliases and update each and everyone of them when they change You have the alias registered once Especially if you autogenerates the properties using T4 You can always go back to umbraco s own GetPropertyValue Just add a type parameter You have complete control over what types your property values are fetched as and the code

    Original URL path: http://ndesoft.dk/2014/03/04/umbraco-net-magic/ (2016-04-28)
    Open archived version from archive

  • Nick Frederiksen
    a real mvc app using umbraco How to create a real MVC app using umbraco 20 Why NOT to use umbraco as a data store I have recently made a great fuzz on twitter by saying I don t want people to use the content section of umbraco as a data store A lot of people did not agree and then the debate began The feedback was so overwhelming neither me nor my coworkers could keep track on who what and Posted on May 11 2013 by Nick Frederiksen in umbraco Web Tags best practices cms crm data base data store database datastore ecommerce erp umbraco social news 792 http ndesoft dk 2013 05 11 why not to use umbraco as a data store Why NOT to use umbraco as a data store 7 How to make localized models in Umbraco MVC MVC it s the sh t Everything is so much easier when we use MVC So when Umbraco came out with version 5 I was super happy because I could now use my favorite framework on my favorite CMS Then Umbraco killed v5 and we had to go back to webforms and simple razors BUT then Umbraco Posted on April 20 2013 by Nick Frederiksen in ASP NET MVC C Programmering Web Tags annotations attributes data annotations dataannotations dictionary localization localized model models mvc umbraco umbraco dictionary umbraco mvc validation social news 780 http ndesoft dk 2013 04 20 how to make localized models in umbraco mvc How to make localized models in Umbraco MVC 8 Database design on user defined properties As a developer I often get across some database designs that are quite complex caused by a developer not quite understanding the problem we ve all been there and therefore cannot solve it correctly The problem is as follows or similar You have 2 tables It s quite simple you have two types of data media and Posted on April 13 2013 by Nick Frederiksen in C Database Programmering Tags architecture database database architecture database structure db dynamic entity framework EntityFramework inheritance properties server sql SQL Server structure T SQL social news 758 http ndesoft dk 2013 04 13 database design on user defined properties Database design on user defined properties 0 IEnumerable why use it Okay first off I really love the IEnumerable T interface and I use it excessively throughout my applications Almost any list or collection throughout the NET framework implements this interface It exposes only one method GetEnumerator but this method is your friend in almost any circumstance This method returns an Enumerator which again exposes methods used Posted on January 15 2013 by Nick Frederiksen in C Generelt Programmering Tags NET C Enumerators IEnumerable List performace yield yield return social news 666 http ndesoft dk 2013 01 15 ienumerable why use it IEnumerable why use it 2 New site I know it s not long since my last visual transformations but I feel I need to keep searching for a theme

    Original URL path: http://ndesoft.dk/author/admin/ (2016-04-28)
    Open archived version from archive

  • ASP.NET MVC Archives - NDesoft
    NMultiSelect I have begun work on a future version of the plug in version 2 0 At the moment that version has the following features that the current 1 5 4 doesn t The new features at the moment are Full jQuery 1 6 compatibility I like to move Posted on July 14 2011 by Nick Frederiksen in ASP NET MVC CSS Javascript jQuery NMultiselect PHP Web XHTML Tags asp net mvc CSS dhtml features future future features javascript jQuery jQuery Multi Select jquery multiselect jQuery plugin jQuery Select new features NMultiSelect PHP select select box wishlist social news 616 http ndesoft dk 2011 07 14 future of nmultiselect Future of NMultiSelect 3 NMultiSelect 1 5 4 Just a service update I think I was way to fast in releasing the 1 5 3 version It was extremely buggy had a few bugs and didn t live up to the standards I think a release from me should meet So therefore forget the 1 5 3 throw it away and never look back and get the latest NMultiSelect Posted on July 14 2011 by Nick Frederiksen in ASP NET MVC CSS Javascript jQuery NMultiselect PHP Web XHTML Tags asp net mvc CSS dhtml javascript jQuery jQuery Multi Select jquery multiselect jQuery plugin jQuery Select NMultiSelect PHP select select box xml social news 613 http ndesoft dk 2011 07 14 nmultiselect 1 5 4 NMultiSelect 1 5 4 3 Quick bug fix new features and Github Hi sorry about the time since my last post I ve just been so damn busy After being notified about a serious bug a missing function thanks wilco and a few new features thanks Jimmy I ve decided to add the project to github All source code is now located on https github com JohnDoe3000 NMultiSelect except for pre 1 5 3 releases The code Posted on July 11 2011 by Nick Frederiksen in ASP NET MVC CSS Javascript jQuery NMultiselect PHP XHTML Tags asp net mvc javascript jQuery jQuery Multi Select jquery multiselect jQuery plugin jQuery Select multiselect NMultiSelect NMultiSelect 1 5 3 select select box social news 607 http ndesoft dk 2011 07 11 quick bug fix new features and github Quick bug fix new features and Github 0 NMultiSelect v 1 5 2 UPDATE I know this is a very popular version but I have made an update for it It has more features and is much more stable You can always find the latest NMultiSelect version here http ndesoft dk category web js nmultiselect js OK I know I m just throwing new versions out but what else to do When you guys ask me Posted on May 10 2011 by Nick Frederiksen in ASP NET MVC CSS Javascript jQuery NMultiselect PHP Web XHTML Tags asp net mvc client javascript jQuery jQuery Multi Select jQuery plugin jQuery Select NMultiSelect PHP select select box server social news 561 http ndesoft dk 2011 05 10 nmultiselect v 1 5 2 NMultiSelect v 1

    Original URL path: http://ndesoft.dk/category/web/asp-net-mvc/ (2016-04-28)
    Open archived version from archive