public async Task <IActionResult> Create(PhotoCreateViewModel model) { if (ModelState.IsValid) { if (model.Image == null) { _clientNotification.AddToastNotification("You Have to Upload An Image!", NotificationHelper.NotificationType.error, new ToastNotificationOption { NewestOnTop = true, CloseButton = true, PositionClass = "toast-top-right", PreventDuplicates = true }); return(View(model)); } if (model.Image.Length > _options.MaxBytes) { _clientNotification.AddToastNotification("Image File size Exceeded", NotificationHelper.NotificationType.error, new ToastNotificationOption { NewestOnTop = true, CloseButton = true, PositionClass = "toast-top-right", PreventDuplicates = true }); return(View(model)); } if (!_options.IsSupported(model.Image.FileName)) { _clientNotification.AddToastNotification("Invalid File Type", NotificationHelper.NotificationType.error, new ToastNotificationOption { NewestOnTop = true, CloseButton = true, PositionClass = "toast-top-right", PreventDuplicates = true }); } else { var photo = new Photo { Id = Guid.NewGuid().ToString().Replace("-", string.Empty), Name = model.Name, Description = model.Description, Category = model.Category, PhotoUrl = _fileManager.SaveImage(model.Image), FaceBookLink = model.FacebookLink, InstagramLink = model.InstagramLink, TwitterLink = model.TwitterLink }; await _photoRepo.AddPhoto(photo); await _photoRepo.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } _clientNotification.AddToastNotification("You Have Errors", NotificationHelper.NotificationType.error, new ToastNotificationOption { NewestOnTop = true, CloseButton = true, PositionClass = "toast-top-right", PreventDuplicates = true }); return(View(model)); }