Ways to pass information from a controller to a view in ASP.NET MVC

There are three ways to pass information from a controller to a view:

  1. As a dynamic type (using @model dynamic)
  2. As a strongly typed model object.
  3. Using the ViewBag

See the sample list and three different actions for my HomeController:

List<People> peopleList = new List<People>
new People { Name = "Juan",Surname="Lazario",PhoneNumber=0539647},
new People { Name = "Cris",Surname="Tormes",PhoneNumber=0539647},
new People { Name = "Bego",Surname="Calvo",PhoneNumber=0539647},
new People { Name = "Manu",Surname="Martinez",PhoneNumber=0539647}

public ActionResult Dynamic()
return View(peopleList);

public ActionResult StronglyTyped()
return View(peopleList);

public ActionResult ViewBagAction()
ViewBag.People = peopleList;
return View();

1.As a dynamic type (using @model dynamic)

Continue reading

Posted in MVC | Tagged , , | Leave a comment

Basics of LINQ II

After a very simple beginning of LINQ let’s continue to play with it more.

In this article, I will try to share some basic methods such as First,Last, Max and Min.

1. Numbers Example:

Let’s create an int array with some numbers and find the first number, last number, first number which is greater then 4, first odd number and number less then 6.

var numbers = new int[] { 2, 3, 4, 5, 6, 7, 8, 9 };

 var firstNumber = numbers.First(); // = 2

 var lastNumber = numbers.Last(); // = 9 

 var firstNumberGreaterThenFour = numbers.First(t => t > 4) ; // = 5

 var firstOddNumber = numbers.First(n => n % 2 == 1); // = 3

 var lastNumberLessThanSix = numbers.Last(n => n < 6); // = 5

2. My Friends

In this part, I’ve created a custom class called Friend and made a list of my friend with their age. Continue reading

Posted in LINQ | Tagged , , , , , | Leave a comment

Change color based on field value in Jaspersoft Studio

Change color based on field value in Jaspersoft Studio

We may change the color, font size and style of the field value based on a condition.

For example, we have two fields called $F{numberofissues} and $F{projectname}. We want to highlight $F{projectname} by styling it with red color, font size 16 and bold style if the number of issue is greater or equal than 30.

1. Create a style

a6vgvbt Continue reading

Posted in Jaspersoft Studio, Uncategorized | Tagged , , | Leave a comment

Copying categories in Redmine

It looks that many people want to see the option to copy to categories of parent project into sub project. So far, it is not a default feature of Redmine. If you have so many projects and categories to write them manually, you can write once and use the SQL command below to copy them.

The table issue_categories in Redmine keeps the records of categories of the projects, you just need to copy one project to new project.

    project_id = 61;

Here 61 is the ID of the projects that I copy from and 71 is the new project that I want to copy categories to.

Posted in Redmine | Tagged , , | Leave a comment

Floor, Ceiling and Rounding with MySQL

I was trying to get the average solution time of issues in Redmine per tracker type. In order to get the average time, I first selected creation time of issue and extracted it from the date of solution of the issue (this doesn’t mean it is closed, it is to say status is updated with the id =X),  after that I listed the average of each day.

ROUND(AVG(DATEDIFF(journals.created_on,issues.created_on))) AverageSolutionTimeRounded,

Some mathematical functions of MySQL could be a useful. Here they are: Continue reading

Posted in MySQL, Uncategorized | Tagged , , , | Leave a comment

Simple XML Reading,Writing and Serialization

Altough JSON became more common, XML is still an important markup language. As a snippet, I created an example project which will be creating a Books.xml file and reading it from the file.

First of all, let’s create a class called Book with parameters of book name, writer and list of readers.

 public class Book 
 private string bookName;
 public string BookName 
 get { return bookName; }
 set { bookName = value; }

 private string bookWriter;
 public string BookWriter
 get { return bookWriter; }
 set { bookWriter = value; }

 private List<string> bookReaders = new List<string>();
 public List<string> BookReaders 
 get { return bookReaders; }
 set { bookReaders = value; }

Continue reading

Posted in C# | Tagged , , | Leave a comment

Oracle sysdate year problem

I have been trying to solve the problem that I encounter when I call a Oracle function in my code. Oracle function takes one number and date as parameteres:


And I was calling the function in my code like


This code is already a wrong approach; trying to convert sysdate which is already a date to a date. I couldn’t change it as it is used by many other applications. But the same code above gave different results in different servers. I realized that the problem was the date format. That is to say how server interprets sysdate parameter of oracle.

When I called to_date(sysdate) (select to_date(sysdate) from dual;) I got 09.12.2015 normally but in a new server I got 09.12.0015 which caused problem for my oracle function.

I thought that as it is an Oracle term, sysdate gave the current datetime from Oracle server but it was not.

Depending on the client server’s settings, the date format might differ. There are two options you can do: Continue reading

Posted in ORACLE | Tagged | Leave a comment