예제 #1
0
 public ActionResult Create(CommunityTopic model, int[] uploadedfile)
 {
     if (ModelState.IsValid)
     {
         if (uploadedfile != null)
         {
             model.AttachmentFiles = new List <File>();
             foreach (int id in uploadedfile)
             {
                 File file = fileService.getFile(id);
                 if (file != null)
                 {
                     model.AttachmentFiles.Add(file);
                 }
             }
         }
         model.InsertDate      = DateTime.UtcNow;
         model.LastUpdatedDate = DateTime.UtcNow;
         ApplicationUser user = memberService.GetUser(User.Identity.Name);
         model.AuthorUserID      = user.Id;
         model.LastUpdatedUserID = user.Id;
         communityService.CreateTopic(model);
         communityService.SaveTopic();
         TempData["ReloadData"] = true;
         return(RedirectToAction("Index"));
     }
     if (uploadedfile != null)
     {
         model.AttachmentFiles = new List <File>();
         foreach (var id in uploadedfile)
         {
             File file = fileService.getFile(id);
             if (file != null)
             {
                 model.AttachmentFiles.Add(file);
             }
         }
     }
     return(View(model));
 }