public IActionResult Create(AgentViewModel model) { if (model == null) { return(NotFound()); } if (ModelState.IsValid) { var agent = _mapper.Map <AgentViewModel, Agent>(model); agent.AddedBy = _admin.Name; agent.AddedDate = DateTime.Now; if (model.File != null) { agent.Image = _fileManager.Upload(model.File); } else { agent.Image = null; } _homeRepository.AddAgent(agent); return(RedirectToAction("index")); } return(View(model)); }