public async Task <IActionResult> CreateRecord(NoticeCreateModel model)
        {
            try
            {
                User currentUser = await _userManager.GetUserAsync(User);

                _noticeService.CreateNotice(model, currentUser.Id);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Beispiel #2
0
 public void CreateNotice(NoticeCreateModel model, int currentUserId)
 {
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         var notice = Mapper.Map <Notice>(model);
         notice.UserId    = currentUserId;
         notice.CreatedOn = DateTime.Now;
         _fileSaver.SaveFile(notice, model.Image);
         var currentNotice = unitOfWork.Notices.Create(notice);
         foreach (var img in model.ImgsCollection)
         {
             var galleryModel = new GalleryImage
             {
                 Image    = _dbFileSaver.GetImageBytes(img),
                 NoticeId = currentUserId
             };
             unitOfWork.GalleryImages.Create(galleryModel);
         }
         unitOfWork.Notices.Create(notice);
     }
 }