Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,ProjectName,TaskName,StartDate,EndDate,ClientName,ClientAdress")] CreateProjectModel createProjectModel)
        {
            bool valid = true;

            if (DateTime.Compare(createProjectModel.StartDate, createProjectModel.EndDate) > 0)
            {
                ModelState.AddModelError("", "Start Date cannot be greater than End Date");
                valid = false;
            }
            if (ModelState.IsValid && valid)
            {
                _context.Add(createProjectModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(createProjectModel));
        }