public async Task <IActionResult> Create([Bind("ProjectTitle,Description,Skills,Price,DueDate,ContactEmail")] Work work) { if (!(await _userManager.GetUserAsync(User)).Role.Equals("client")) { return(NotFound()); } // Days must be at least 10 after now if ((work.DueDate - DateTime.Now).Days < 10) { ModelState.AddModelError("DueDate", "The time set must be at least 10 days after today"); } if (!string.IsNullOrEmpty(work.Skills)) { ModelState.AddModelError("Skills", "The skills field requires atleast one entry"); } // Add other missing details during creation of the job work.Owner = await _userManager.GetUserAsync(User); work.PostDate = DateTime.Now; // work.Skills = work.Skills.ToUpper(); work.WorkStatus = "Unassigned"; if (ModelState.IsValid) { _context.Add(work); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(work)); }
public async Task <IActionResult> Create([Bind("ID,UserName,Proffesion,Project,Rating,completeDate")] History history) { if (ModelState.IsValid) { _context.Add(history); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(history)); }