Reputation: 877
I wants to count the number of days between given start date and end date.
where start date and end date will entered by the user. using that i have to count total days between them.
my database is as below
leave_id int leave_start_date DateTime leave_end_date DateTime leave_days int
and my .cs(class) files of Model are as below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
namespace LeaveModule.Models
{
public class LeaveSet
{
public int user_id { get; set; }
public DateTime leave_start_date { get; set; }
public DateTime leave_end_date { get; set; }
public string leave_description { get; set; }
public decimal leave_days { get; set; }
}
}
2nd file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ProjectManagementSystem.Models;
namespace LeaveModule.Models
{
public class LeaveSetFetch
{
public static IList<LeaveSet> all()
{
IList<LeaveSet> result =
(IList<LeaveSet>)HttpContext.Current.Session["leave"];
if (result == null)
{
HttpContext.Current.Session["leave"] = result =
(from l in new ProjectManagementSystemEntities3().leave_master
select new LeaveSet
{
user_id = l.user_id,
leave_start_date = l.leave_start_date,
leave_end_date = l.leave_end_date,
leave_description = l.leave_description,
leave_days = l.leave_days,
// is_valid = l.is_valid,
}).ToList();
}
return result;
}
}
}
So how can i do that in MVC3?
Thanks in advance..
Upvotes: 0
Views: 5203