public async Task <IActionResult> Add(BaseDataVM baseData) { try { if (ModelState.IsValid) { if (Request.Form.Files != null && Request.Form.Files.Count > 0) { baseData.Icon = await Upload(Request.Form.Files[0]); } await baseDataService.AddAsync(new BaseDataDto { ID = Guid.NewGuid(), CreateTime = DateTime.Now, Icon = baseData.Icon, IsDefault = Convert.ToString(baseData.IsDefault), Key = baseData.Key, Type = baseData.Type, UpdateTime = DateTime.Now, Value = baseData.Value }); return(RedirectToAction("Index", "BaseData")); } } catch (Exception ex) { TempData["error"] = ex.Message; } return(View(baseData)); }