// GET: Project public ActionResult Index() { try { DBLogErrorInfo.LogErrorInfo_in_DB("Inside controller - Home Page Loaded ...", "Info"); ProjectInfoViewModel vm = new ProjectInfoViewModel(); DBLogErrorInfo.LogErrorInfo_in_DB("Inside controller - View Model Created...", "Info"); DBLogErrorInfo.LogErrorInfo_in_DB("Inside controller - HandleRequest called...", "Info"); //if (Session["MyUserId"] != null) { // ViewBag.MyUserId = Session["MyUserId"]; //vm.Entity.User_ID = Convert.ToInt32(Convert.ToString(Session["User_ID"])); // ViewBag.UserName = Session["UserName"]; //vm.Entity.FirstName = Convert.ToString(Session["FirstName"]); } vm.HandleRequest(); DBLogErrorInfo.LogErrorInfo_in_DB("Inside controller - HandleRequest Completed...", "Info"); return(View(vm)); } catch (Exception ex) { DBLogErrorInfo.LogErrorInfo_in_DB(ex.Message, "Error"); return(View("Error", new HandleErrorInfo(ex, "EmployeeInfo", "Create"))); } }
public IActionResult SaveProjectInfo(ProjectInfoViewModel vm) { var response = new JsonResponse(); try { if (ModelState.IsValid) { var project = mapper.Map <Project>(vm); response.Success = projectService.UpdateProjectInfo(project); if (!response.Success) { response.Notification = "An error occurred saving your changes"; var refresh = projectService.GetById(vm.Id); if (refresh != null) { response.Data = mapper.Map <ProjectInfoViewModel>(refresh); } } } else { response.Data = vm; response.Notification = "An error occurred saving your changes"; } } catch (Exception ex) { response.Success = false; response.Notification = "An error occurred saving your changes."; logger.LogError(ex, response.Notification); } return(Json(response)); }
public MainWindow(string projectId) { InitializeComponent(); pivm = new ProjectInfoViewModel(projectId, this, functionExpander, featureExpander, extraFeatureExpander) { Parent = this }; DataContext = pivm; }
public IActionResult AddVideos(int id) { var projectTitle = _projectService.GetSingleProject(id).Data.Title; var projectInfoViewModel = new ProjectInfoViewModel { ProjectId = id, ProjectTitle = projectTitle }; return(View(projectInfoViewModel)); }
public IActionResult CreateRewardPackage(int id) { var projectTitle = _projectService.GetSingleProject(id).Data.Title; var projectInfoViewModel = new ProjectInfoViewModel { ProjectId = id, ProjectTitle = projectTitle, RewardOptions = new CreateRewardPackageOptions(), PostOptions = new CreatePostOptions() }; return(View(projectInfoViewModel)); }
public void IndexTest() { //TestControllerBuilder builder = new TestControllerBuilder(); // builder.InitializeController(usercontroller); var projcontroller = new ProjectController(); ProjectInfoViewModel prjVM = new ProjectInfoViewModel(); ProjectInfo prjInfo = new ProjectInfo(); prjInfo.Project = "Test Proj"; prjInfo.StartDate = DateTime.Now; prjInfo.EndDate = DateTime.Now.AddDays(1); prjInfo.Priority = 1; prjVM.Entity = prjInfo; var uresult = (ActionResult)projcontroller.Index(prjVM); var controller = new ProjectController(); var result = (ViewResult)controller.Index(); Assert.AreEqual("LIST", ((SPAData.ProjectInfoViewModel)result.Model).EventCommand.ToUpper()); Assert.AreNotEqual(0, ((SPAData.ProjectInfoViewModel)result.Model).ProjectsInfo.Count); }
public ActionResult Index(ProjectInfoViewModel vm) { vm.IsValid = ModelState.IsValid; //ViewBag.startDate = DateTime.Now; //ViewBag.endDate = DateTime.Now; //vm.Entity.UserId = Convert.ToInt32(Convert.ToString(Session["MyUserId"])); //vm.Entity.UserName = Convert.ToString(Session["UserName"]); vm.HandleRequest(); if (vm.IsValid) { ModelState.Clear(); } else { foreach (KeyValuePair <String, string> item in vm.ValidationErrors) { ModelState.AddModelError(item.Key, item.Value); } } return(View(vm)); }
public void Project_Save_Test() { var controller = new ProjectController(); ProjectInfoViewModel vm = new ProjectInfoViewModel(); int intialcount = vm.ProjectsInfo.Count; var result = (ViewResult)controller.Index(); int countbeforeInsert = ((SPAData.ProjectInfoViewModel)result.Model).ProjectsInfo.Count; vm.EventCommand = "save"; vm.Mode = "Add"; ProjectInfo myTestEntity = new ProjectInfo(); myTestEntity.Project = "Test Proj" + DateTime.Now.ToString(); myTestEntity.StartDate = DateTime.Now; myTestEntity.EndDate = DateTime.Now.AddDays(1); myTestEntity.Priority = 1; vm.Entity = myTestEntity; result = (ViewResult)controller.Index(vm); Assert.AreEqual(0, intialcount); Assert.AreNotEqual(0, countbeforeInsert); Assert.AreEqual(countbeforeInsert + 1, ((SPAData.ProjectInfoViewModel)result.Model).ProjectsInfo.Count); }
public async Task <IActionResult> Index() { List <ProjectInfoViewModel> projects = new List <ProjectInfoViewModel>(); var items = await this.context.ProjectRepository.GetAllProjectAsync(); if (items.Any()) { foreach (var item in items) { ProjectInfoViewModel project = new ProjectInfoViewModel { Id = item.Id, Name = this.GetCulture(item.NameRu, item.NameEn), }; project.Image = new ImageViewModel(); var image = await this.context.ImageRepository.GetTitleImgAsync(item.Id); if (image != null) { string imageBase64Data = Convert.ToBase64String(image.Data); string imageDataURL = string.Format("data:{0};base64,{1}", image.ContentType, imageBase64Data); project.Image.TitleImage = imageDataURL; } project.ConstructionState = Converter.ToConstructionState(item.ConstructionState); project.SystemState = Converter.ToSystemState(item.SystemState); project.UpdateDate = item.UpdateDate; projects.Add(project); } } return(this.View(projects)); }
public Dictionary <int, string> Resolve(Project source, ProjectInfoViewModel destination, Dictionary <int, string> destMember, ResolutionContext context) { var type = typeof(ProjectStatus); return(Enum.GetValues(type).Cast <int>().ToDictionary(e => e, e => Enum.GetName(type, e))); }
public ProjectInfoPage() { this.InitializeComponent(); _viewModel = this.DataContext as ProjectInfoViewModel; }