public IActionResult savePayType(PayType type) { if (_personalContext.PayType.Contains(type)) { _personalContext.Update(type); } else { _personalContext.Add(type); } _personalContext.SaveChanges(); return(Ok()); }
public async Task <IActionResult> Create(string Content) { PersonalPost personalPost = new PersonalPost(); personalPost.Content = Content; if (ModelState.IsValid) { personalPost.Id = Guid.NewGuid(); List <IFormFile> images = Request.Form.Files.Where(f => f.Name == "images[]").ToList(); string[] imgNameList = _UploadImages(images, personalPost.Id.ToString()); personalPost.ImageUrls = (imgNameList != null) ? string.Join(";", imgNameList) : null; personalPost.InsertDate = DateTime.Now; personalPost.LastUpdated = DateTime.Now; personalPost.UserId = _userManager.GetUserId(User); _context.Add(personalPost); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(personalPost)); }