public class Reg_SubCategoryMV
{
public Reg_SubCategoryMV()
{
List_Status = new List<StatusMV>();
foreach (var status in new DatabaseLayer.Pro_EcommerceDbEntities().StatusTables.ToList())
{
List_Status.Add(new StatusMV()
{
StatusID = status.StatusID,
StatusTitle = status.StatusTitle
});
}
List_SubCategories = new List<SubCategoryMV>();
foreach (var category in new DatabaseLayer.Pro_EcommerceDbEntities().SubCategoryTables.ToList())
{
var createdby = new DatabaseLayer.Pro_EcommerceDbEntities().UserTables.Find(category.CreatedBy_UserID);
var status = new DatabaseLayer.Pro_EcommerceDbEntities().StatusTables.Find(category.StatusID);
var adddatetime = category.CreatedDate + category.CreatedTime;
List_SubCategories.Add(new SubCategoryMV()
{
Sub_CategoryID = category.Sub_CategoryID,
Sub_CategoryTitle = category.Sub_CategoryTitle,
CreatedBy = createdby.UserName,
CreatedDateTime = adddatetime.ToString(),
Status = status.StatusTitle
});
}
}
public Reg_SubCategoryMV(int? id)
{
List_Status = new List<StatusMV>();
foreach (var status in new DatabaseLayer.Pro_EcommerceDbEntities().StatusTables.ToList())
{
List_Status.Add(new StatusMV() {
StatusID = status.StatusID,
StatusTitle = status.StatusTitle
});
}
List_SubCategories = new List<SubCategoryMV>();
foreach (var category in new DatabaseLayer.Pro_EcommerceDbEntities().SubCategoryTables.ToList())
{
var createdby = new DatabaseLayer.Pro_EcommerceDbEntities().UserTables.Find(category.CreatedBy_UserID);
var status = new DatabaseLayer.Pro_EcommerceDbEntities().StatusTables.Find(category.StatusID);
var adddatetime = category.CreatedDate + category.CreatedTime;
List_SubCategories.Add(new SubCategoryMV()
{
Sub_CategoryID = category.Sub_CategoryID,
Sub_CategoryTitle = category.Sub_CategoryTitle,
CreatedBy = createdby.UserName,
CreatedDateTime = adddatetime.ToString(),
Status = status.StatusTitle
});
}
var editcategory = new DatabaseLayer.Pro_EcommerceDbEntities().SubCategoryTables.Find(id);
if (editcategory != null)
{
Sub_CategoryID = editcategory.Sub_CategoryID;
Sub_CategoryTitle = editcategory.Sub_CategoryTitle;
StatusID = editcategory.StatusID;
}
else
{
Sub_CategoryID = 0;
Sub_CategoryTitle = string.Empty;
StatusID = 0;
}
}
public int Sub_CategoryID { get; set; }
[Required(ErrorMessage = "Required*")]
[Display(Name = "Sub Category")]
public string Sub_CategoryTitle { get; set; }
[Required(ErrorMessage = "Required*")]
[Display(Name = "Status")]
public int StatusID { get; set; }
public virtual List<SubCategoryMV> List_SubCategories { get; set; }
public virtual List<StatusMV> List_Status { get; set; }
}
Comments
Post a Comment