Problem
Throughout my career, I met many professionals in their respective fields and exchange a few words, and obtained their business cards as well. I used to store them in my cardholder or simply in my cupboard but it was quite frustrating to find a specific business card of someone when you need their services. moreover, there was quite some more annoying situation where I was not at home and don't have any business card at my reach but badly need to contact someone to reach out for their services so bearing in mind that modern problem requires modern solution I decided to create my own application which will solve the issue to store, search and carry all those business cards around.
Solution
- my first solution was to download an already existing application, but some were paid application some were freemium and all of them did not have the specific feature that I want to use in my day to day basis
- I started creating prototypes using two Xamarin which is a cross-platform development for both IOS and android. Due to the fact that I had to learn Xamarin and was i bite rusty when it comes to native development of an android application, I scrap the idea of a mobile application
- using Angular framework as client-side and ASP.Net core Web API seems a good idea at first but to develop a simple application with simple CRUD operations will be time and resource waste
- since I wanted a simple application I also considered using a console application, I started the prototype but scrap the idea as well because in terms of experience it was not user friendly.
- While having a conversation which a colleague, he mentioned a technology called Blazor from Microsoft thus I checked the documentation of the technology online and I was quite amazed and fascinated by the simplicity yet the power of this technology thus I decide to give it a try
Prototype
Using Xamarin technology
Views
Model
Screenshot
Using console application
Main menu
Navigation
Navigation through the console application was pretty much simple, using numbers it would be practical to navigate through menu such as view all cards, view details of a card, add a card, and so on.
View cards and details
CardHolder web Application
To build up the application I used Blazor technology, developed and maintained by Microsoft. It is still considered as a "young" technology with mixed reviews by as far as concern my personal opinion, the technology in question is very powerful and easy to understand the logic of the framework. You don't need to learn alternate technology to develop a full-fledged web application compare to the most common approach where the client-side will be developed using framework such as angular, vue.js, react and so and the backend be a common API using maybe ASP.NET web API
Technology
The technologies used for this project are:
- Boostrap for visual appearance, HTML and CSS
- Blazor for web development including front and back end
- entity framework core
- SQL server
Overview
Home page/ cards
View a card
Add a card
Toggle cards view
Listview
Card view
Search
The search is one of the most used feature in the application. it will search every field which contained the searched keyword.
source code snippets
| public List<CardViewModel> Search(string searchWord) |
| { |
| try |
| { |
| List<CardViewModel> result = new List<CardViewModel>(); |
| using (var context = new CardHolderContext()) |
| { |
| result = (from crd in context.Cards |
| join cat in context.CategoryMasters on crd.CategoryId equals cat.CategoryId |
| join con in context.ContactDetails on crd.CardId equals con.CardId |
| where |
| crd.CompanyName.Contains(searchWord) || |
| crd.OwnerName.Contains(searchWord) || |
| cat.MasterValue.Contains(searchWord) |
| select new CardViewModel() |
| { |
| CardDetails = crd, |
| Category = cat, |
| Contact = con |
| } |
| ).ToList(); |
| } |
| return result; |
| } |
| catch (Exception ex) |
| { |
| throw new Exception(ex.Message); |
| } |
| |
| } |
| public void Update(CardViewModel card) |
| { |
| try |
| { |
| using (var context = new CardHolderContext()) |
| { |
| var updateCard = context.Cards.Where(x => x.CardId == card.CardDetails.CardId).FirstOrDefault(); |
| updateCard.CompanyName = card.CardDetails.CompanyName; |
| updateCard.CategoryId = card.CardDetails.CategoryId; |
| updateCard.JobTitle = card.CardDetails.JobTitle; |
| updateCard.OwnerName = card.CardDetails.OwnerName; |
| updateCard.Tagline = card.CardDetails.JobTitle; |
| updateCard.Website = card.CardDetails.Website; |
| context.SaveChanges(); |
| |
| var updateContact = context.ContactDetails.Where(x => x.CardId == card.CardDetails.CardId).FirstOrDefault(); |
| updateContact.City = card.Contact.City ; |
| updateContact.Country = card.Contact.Country; |
| updateContact.Email = card.Contact.Email; |
| updateContact.FixNumber = card.Contact.FixNumber; |
| updateContact.MobileNumber = card.Contact.MobileNumber; |
| updateContact.Street = card.Contact.Street; |
| context.SaveChanges(); |
| |
| var deleteSocial = context.SocialMedia.Where(x => x.CardId == card.CardDetails.CardId).ToList(); |
| context.SocialMedia.RemoveRange(deleteSocial); |
| context.SaveChanges(); |
| |
| if (card.SocialMedia.Count > 0) |
| { |
| foreach (var item in card.SocialMedia) |
| { |
| item.CardId = card.CardDetails.CardId; |
| item.SocialId = 0; |
| context.SocialMedia.Add(item); |
| } |
| } |
| context.SaveChanges(); |
| } |
| } |
| catch (Exception ex) |
| { |
| throw new Exception(ex.Message); |
| } |
| } |
| public void Delete(int id) |
| { |
| try |
| { |
| using (var context = new CardHolderContext()) |
| { |
| var deleteCard = context.Cards.Where(x => x.CardId == id).FirstOrDefault(); |
| context.Cards.Remove(deleteCard); |
| var deleteSocial = context.SocialMedia.Where(x => x.CardId == id).ToList(); |
| context.SocialMedia.RemoveRange(deleteSocial); |
| |
| context.SaveChanges(); |
| } |
| } |
| catch (Exception ex) |
| { |
| throw new Exception(ex.Message); |
| } |
| } |
| public CardViewModel Read(int id) |
| { |
| try |
| { |
| CardViewModel result = new CardViewModel(); |
| using (var context = new CardHolderContext()) |
| { |
| result = (from crd in context.Cards |
| where crd.CardId == id |
| join cat in context.CategoryMasters on crd.CategoryId equals cat.CategoryId |
| join con in context.ContactDetails on crd.CardId equals con.CardId |
| select new CardViewModel() |
| { |
| CardDetails = crd, |
| Category = cat, |
| Contact = con |
| } |
| ).FirstOrDefault(); |
| |
| if (result == null) |
| throw new Exception("Invalid id"); |
| |
| result.SocialMedia = new List<SocialMedium>(); |
| result.SocialMedia = (from soc in context.SocialMedia |
| where soc.CardId == id |
| select soc |
| ).ToList(); |
| } |
| return result; |
| } |
| catch (Exception ex) |
| { |
| throw new Exception(ex.Message); |
| } |
| } |
| |
| public void Create(CardViewModel card) |
| { |
| try |
| { |
| using (var context = new CardHolderContext()) |
| { |
| context.Cards.Add(card.CardDetails); |
| context.SaveChanges(); |
| |
| card.Contact.CardId = card.CardDetails.CardId; |
| context.ContactDetails.Add(card.Contact); |
| |
| if (card.SocialMedia.Count > 0) |
| { |
| foreach (var item in card.SocialMedia) |
| { |
| item.CardId = card.CardDetails.CardId; |
| } |
| } |
| |
| context.SocialMedia.AddRange(card.SocialMedia); |
| context.SaveChanges(); |
| |
| } |
| } |
| catch (Exception ex) |
| { |
| throw new Exception(ex.Message); |
| } |
| } |
| public List<CardViewModel> Retrieve() |
| { |
| try |
| { |
| List<CardViewModel> result = new List<CardViewModel>(); |
| using (var context = new CardHolderContext()) |
| { |
| result = (from crd in context.Cards |
| join cat in context.CategoryMasters on crd.CategoryId equals cat.CategoryId |
| join con in context.ContactDetails on crd.CardId equals con.CardId |
| select new CardViewModel() |
| { |
| CardDetails = crd, |
| Category = cat, |
| Contact = con |
| } |
| ).ToList(); |
| } |
| return result; |
| } |
| catch (Exception ex) |
| { |
| throw new Exception(ex.Message); |
| } |
| } |
Great information shared in this blog. Helps in gaining concepts about new information and concepts.
ReplyDeleteAwsome information provided. Very useful for the beginners.
Dot Net Blazor
Hire Blazor Developers
Very useful information to everyone thanks for sharing.
ReplyDeleteAzure DevOps Online Training
Azure DevOps Training
Azure DevOps Online Training in Hyderabad
Azure Devops Training Online