ASP.NET MVC Solution Architecture – Best Practices

Choosing the right architecture for Web Applications is a must, especially for large scale ones. Using the default Visual Studio ASP.NET MVC Web Application project templates, adding controllers with Scaffolding options, just to bootstrap your application and create pages and data in just a few minutes, sounds awesome for sure, but let’s be honest it’s not always the right choise. Peeking all the default options, keeping business, data and presentation logic in the same project will impact several factors in your solutions, such as scalability, usability or testability. In this post, will see how to keep things clean, creating a highly loosely coupled ASP.NET MVC Solution, where Data Access, Business and Presentation layers are defined in the right manner. To do this, we ‘ll make use of several patterns and frameworks, some of those are presented below.

Entity Framework Code First development
Generic Repository Pattern
Dependency Injection using Autofac framework
Automapper

ASP.NET MVC Solution Architecture – Best Practices
https://github.com/chsakell/mvcarchitecture

MVC C# Cookie management

Declare Object Class

public class LogedInInfo
    {
        public int UserId { get; set; }
        public string UserName { get; set; }
        public string ShopID { get; set; }
        public string ShopName { get; set; }
        public string CounterID { get; set; }
    }


Assign object value and set Cookie

LogedInInfo info = new LogedInInfo(); // assign object to info
var json = JsonConvert.SerializeObject(info);
HttpCookie cookie = new HttpCookie("LogedInInfo", json);
cookie.Expires = DateTime.Now.AddDays(30);                 
HttpContext.Response.Cookies.Add(cookie);
           

Get cookie value from object

 private LogedInInfo GetLogedInInfo()
{
 LogedInInfo info= new LogedInInfo();
 if (HttpContext.Request.Cookies["LogedInInfo"] != null)
  {
  HttpCookie cookie = HttpContext.Request.Cookies.Get("LogedInInfo");
  info = Newtonsoft.Json.JsonConvert.DeserializeObject(cookie.Value) as LogedInInfo;
   }
    return info;
  }

Clear Cookie/Remove Cookie

 if (Request.Cookies["LogedInInfo"] != null)
 {
  var c = new HttpCookie("LogedInInfo");
  c.Expires = DateTime.Now.AddDays(-1);
  Response.Cookies.Add(c);
  }

Get Cookie in ASP.NET *.aspx.cs

LogedInInfo info = new LogedInInfo();
if (Request.Cookies["LogedInInfo"] != null)
{
var value = Request.Cookies["LogedInInfo"].Value;
info = Newtonsoft.Json.JsonConvert.DeserializeObject(value) as LogedInInfo;
}
return info;

Other userfull tricks

//Response.Cookies.Add(cookie);
//HttpContext.Response.Cookies.Remove(“some_cookie_name”);
//HttpContext.Response.SetCookie(cookie);

Response.SetCookie(cookie); //SetCookie is used for update the cookies.
Response.Cookie.Add(cookie); //This is used for Add cookies.

http://stackoverflow.com/questions/19128507/using-cookie-in-asp-net-mvc-4

http://stackoverflow.com/questions/6797350/asp-net-mvc-cookie-implementation

SQL SERVER – Attach mdf file without ldf file in Database

USE [master]
GO
— Method 1: I use this method
EXEC sp_attach_single_file_db @dbname=’TestDb’,
@physname=N’C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf’
GO

— Method 2:

CREATE DATABASE TestDb ON
(FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf’)
FOR ATTACH_REBUILD_LOG
GO

— Method 3:
CREATE DATABASE TestDb ON
( FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf’)
FOR ATTACH
GO

3579_CreateDatabase4Attach

Attaching the Damaged SQL Server Database

USE [master]
GO

CREATE DATABASE [TestDB_Repair]
CONTAINMENT = NONE
ON  PRIMARY
( NAME = N’TestDB_Repair_file1′,
FILENAME = N’E:\MSSQL\TestDB_Repair_1.mdf’,
SIZE = 8MB ,
MAXSIZE = UNLIMITED,
FILEGROWTH = 64MB)
LOG ON
( NAME = N’TestDB_Repair_log_file1′,
FILENAME = N’E:\MSSQL\TestDB_Repair_1.ldf’,
SIZE = 8MB,
MAXSIZE = 2048GB,
FILEGROWTH = 32MB)

Now we set the database offline.

USE master
GO

ALTER DATABASE [TestDB_Repair] SET OFFLINE WITH ROLLBACK IMMEDIATE
GO

At this point we can change the file location of our new database to point to our orphaned mdf file and set the location of the log file to a non-existent file.

USE master
GO

ALTER DATABASE [TestDB_Repair] MODIFY FILE(NAME=’TestDB_Repair_file1′, FILENAME= ‘E:\MSSQL\TestDBCopy.mdf’)
ALTER DATABASE [TestDB_Repair] MODIFY FILE(NAME=’TestDB_Repair_log_file1′, FILENAME= ‘E:\MSSQL\TestDBCopy.ldf’)
GO
Let’s bring the database back online.

USE master
GO

ALTER DATABASE [TestDB_Repair] SET ONLINE
GO

2

Rebuilding the SQL Server Transaction Log

USE master
GO

DBCC TRACEON(3604)
GO

ALTER DATABASE TestDB_Repair SET EMERGENCY
GO

ALTER DATABASE TestDB_Repair SET SINGLE_USER
GO

DBCC CHECKDB('TestDB_Repair', REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS
GO

ALTER DATABASE TestDB_Repair SET MULTI_USER
GO

3

http://littleprograming.blogspot.com/2015/10/sql-server-attach-mdf-file-without-ldf.html

Chosen jQuery plugin with MVC 5

Chosen is a jQuery plugin that makes long, unwieldy select boxes much more user-friendly.

Model:

 public class CustomerCategoryOption
    {
        public int ID { get; set; }
        public string CategoryName { get; set; }
    }

controller:

    public ActionResult Index()
        {
            List customerCategoryOption = new List() { 
              new CustomerCategoryOption{ID=1, CategoryName = "PLATINUM"},
              new CustomerCategoryOption{ID=2, CategoryName = "SILVER"},
              new CustomerCategoryOption{ID=3, CategoryName = "GOLD"},
              new CustomerCategoryOption{ID=4, CategoryName = "ABC"},
              new CustomerCategoryOption{ID=5, CategoryName = "ABD"},
              new CustomerCategoryOption{ID=6, CategoryName = "ABM"},
            };

            ViewBag.CustomerCategory = new SelectList(customerCategoryOption, "ID", "CategoryName");

            return View();
        }

view:


@{
  ViewBag.Title = "Index";
}http://@Url.Content(http://@Url.Content(

@ViewBag.Message

@Html.DropDownList(“ID”, (IEnumerable)ViewBag.CustomerCategory, new { @class = “chosen” })

//

Result:
def

Ref Link:
http://harvesthq.github.io/chosen/
http://utsavized.com/chosen-multiselect-dropdown-list-with-asp-net-mvc3/

j Query DatePicker with HTML code

$(document).ready(function() {
$(“#datepicker”).datepicker( { dateFormat: “yy-mm-dd”, minDate: -40, maxDate:”+2M +5D”});
});

ওয়ার্ডপ্রেস বাংলা বই (wordpress Bangla Book)

ওয়ার্ডপ্রেস ই-বুক প্রাথমিক। ডাউনলোড করতে পারেন খুব সহজেই এখান থেকে।

http://tutohost.com/ebook/wordpress.pdf

লেখকঃ Ariful Islam Shaon
৯০ পৃষ্ঠার পিডেএফ বই ৬.৭৬ মেগাবাইট

Learn Web Design

You can make a good web designer and developer. You can learn more by the following links:

http://www.w3schools.com
http://www.webcoachbd.com
http://techtweets.com.bd/category/web-developing
http://www.bdgeeks.com
http://learncss.tutsplus.com/

Hope these links will help you more to learn.

E-R Diagram Online Bus Ticket System

E-R Diagram Online Bus Ticket System

My Campus in google map

My Campus Map

Jagannath University in Google Map

A program of bubble sort in ascending order

/* A program of bubble sort in ascending order */

#include

int main(void)
{
int i,j,n,array[50],tem;

printf(“Enter how many number are you want to sort , maximum size is 50 :\n”);
scanf(“%d”,&n);

printf(“Now Enter %d numbers :\n”,n);
for(i=0;i
scanf(“%d”,&array[i]);

for(i=1;i<=n-1;i++)
{
for(j=0;j<n-i;j++)

{

if(array[j]>array[j+1e])
{
tem=array[j];
array[j]=array[j+1];
array[j+1]=tem;

}
}
}
printf(“The sorted number are :\n”);
for(i=0;i<n;i++)
printf(“%3d”,array[i]);

return 0;
}

Academic Ranking of World Universities in Computer Science – 2010

Here  are the top 100 world university in computer science

see the link to know the rank list

Programming video tutorials

Here are some video  tutorials of programming . if you fell any interest , please visit the following link