public ActionResult Project(string code) { ProjectMgmt.Project proj = new ProjectMgmt.Project(ConfigurationManager.ConnectionStrings["SystemDS"].ToString(), code); democode.mvc.Models.ProjectModels model = convertToProjectModels(proj); model.ProjectImages = new List<String>(); String projectImagesFolder = model.Folder; //if no folder is listed then just return view if (!string.IsNullOrEmpty(projectImagesFolder)) { if (!projectImagesFolder.EndsWith("/")) projectImagesFolder += "/"; projectImagesFolder += "images/"; //check if folder exist if true then get all images in folder if (Directory.Exists(Server.MapPath("~" + projectImagesFolder))) { System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Server.MapPath("~" + projectImagesFolder)); System.IO.FileInfo[] diar1 = di.GetFiles(); //list the names of all files in the specified directory foreach (System.IO.FileInfo dra in diar1) { if (dra.Extension.ToLower() == ".jpg" || dra.Extension.ToLower() == ".png" || dra.Extension.ToLower() == ".gif") { model.ProjectImages.Add(String.Format("{0}{1}", projectImagesFolder, dra.Name)); } } } } return View(model); }
private ProjectMgmt.Project convertFromProject(democode.mvc.Models.ProjectModels data) { ProjectMgmt.Project p = new ProjectMgmt.Project(); try { p.PID = data.PID; p.Icon = data.Icon; p.Code = data.Code; p.Name = data.Name; p.Description = data.Description; p.EstimatedStartDate = data.EstimatedStartDate; p.EstimatedEndDate = data.EstimatedEndDate; p.ActualStartDate = data.ActualStartDate; p.ActualEndDate = data.ActualEndDate; p.Folder = data.Folder; p.Caption = data.Caption; p.URL = data.URL; p.Organization = data.Organization; return p; } catch (Exception ex) { return null; } }
private ProjectMgmt.Project WebApiModelToDALObject(WebAPI.Models.Project data) { ProjectMgmt.Project dal = new ProjectMgmt.Project(); try { dal.PID = new Guid(data.PID); dal.Icon = data.Icon; dal.Code = data.Code; dal.Name = data.Name; dal.Description = data.Description; dal.EstimatedStartDate = Convert.ToDateTime(data.EstimatedStartDate); dal.EstimatedEndDate = Convert.ToDateTime(data.EstimatedEndDate); dal.ActualStartDate = Convert.ToDateTime(data.ActualStartDate); dal.ActualEndDate = Convert.ToDateTime(data.ActualEndDate); dal.Folder = data.Folder; dal.Caption = data.Caption; dal.URL = data.URL; dal.Organization = data.Organization; return dal; } catch (Exception ex) { return null; } }