Ejemplo n.º 1
0
 public ActionResult CreateProject(ProjectModel newProject)
 {
     try
     {
         var Id = DBHelper.Instance.CreateProject(newProject);
         return Json(new { success = Messages.ProjectCreatedSuccessfully, Id = Id });
     }
     catch (Exception ex)
     {
         return Json(new { errors = ex.Message });
     }
 }
Ejemplo n.º 2
0
        public void ProjectModel_GetDateDisplay()
        {
            DateTime StartDate = new DateTime(2016, 5, 11);
            DateTime EndDate = new DateTime(2016, 5, 12);
            string expectedStartDateDisplay = "5/11/2016";
            string expectedEndDateDisplay = "5/12/2016";

            ProjectModel model = new ProjectModel { StartDate = StartDate, EndDate = EndDate };
            string actualStartDateDisplay = model.StartDateDisplay;
            string actualEndDateDisplay = model.EndDateDisplay;

            Assert.AreEqual(expectedStartDateDisplay, actualStartDateDisplay);
            Assert.AreEqual(expectedEndDateDisplay, actualEndDateDisplay);
        }
Ejemplo n.º 3
0
 public void UpdateProject(ProjectModel model)
 {
     try
     {
         using (ProjectsDB db = new ProjectsDB())
         {
             var project = db.ProjectInfo.Where(p => p.ProjectId == model.ProjectId).FirstOrDefault();
             project.ClientCompanyName = model.ClientCompanyName;
             project.ExecutiveCompanyName = model.ExecutiveCompanyName;
             project.Priority = model.Priority;
             project.StartDate = model.StartDate;
             project.EndDate = model.EndDate;
             project.Comment = model.Comment;
             project.ProjectManagerId = model.ProjectManagerId;
             db.Entry(project).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException("UpdateProject(): ", ex.ToString());
     }
 }
Ejemplo n.º 4
0
 public int CreateProject(ProjectModel model)
 {
     try
     {
         var Mapper = MapperHelper.CreateMap<ProjectModel, ProjectInfo>();
         var project = Mapper.Map<ProjectInfo>(model);
         using (ProjectsDB db = new ProjectsDB())
         {
             db.ProjectInfo.Add(project);
             db.SaveChanges();
             int Id = db.ProjectInfo.Where(p => p.ClientCompanyName == model.ClientCompanyName && p.StartDate == model.StartDate).Select(s => s.ProjectId).FirstOrDefault();
             AddProjectExecutor(Id, model.ProjectManagerId);
             return Id;
         }
     }
     catch (Exception ex)
     {
         throw new DBException("CreateProject(): ", ex.ToString());
     }
 }
Ejemplo n.º 5
0
 public ActionResult UpdateProject(ProjectModel model)
 {
     try
     {
         DBHelper.Instance.UpdateProject(model);
         if (DBHelper.Instance.ValidateProjectExecutor(model.ProjectId, model.ProjectManagerId))
         {
             DBHelper.Instance.AddProjectExecutor(model.ProjectId, model.ProjectManagerId);
         }
         return Json(new { success = Messages.ProjectDetailsUpdatedSuccessfully });
     }
     catch (Exception ex)
     {
         return Json(new { errors = ex.Message });
     }
 }