public ActionResult Create(TaiNguyen model)
 {
     if (ModelState.IsValid)
     {
         using (var scope = new TransactionScope())
         {
             db.TaiNguyen.Add(model);
             db.SaveChanges();
             model.Include(db);
             if (model.laThuMuc)
             {
                 try
                 {
                     Create(model.getFolder());
                     scope.Complete();
                     return(RedirectToAction("Index", new { parent = model.idTaiNguyen }));
                 }
                 catch (Exception e)
                 {
                     ModelState.AddModelError("tenTaiNguyen", e.Message);
                 }
             }
             else
             {
                 try
                 {
                     if (!String.IsNullOrEmpty(model.tepDinhKem))
                     {
                         var file = Request.Files[0];
                         model.tepDinhKem = file.FileName;
                         db.SaveChanges();
                         Upload(file, model.getFolder());
                     }
                     scope.Complete();
                     return(RedirectToAction("Index", new { parent = model.idTaiNguyen }));
                 }
                 catch (Exception e)
                 {
                     ModelState.AddModelError("tepDinhKem", e.Message);
                 }
             }
         }
     }
     return(View(model));
 }
 public ActionResult Rename(TaiNguyen model, string folder)
 {
     if (ModelState.IsValid)
     {
         using (var scope = new TransactionScope())
             try
             {
                 db.Entry(model).State = EntityState.Modified;
                 db.SaveChanges();
                 model.Include(db);
                 if (model.laThuMuc)
                 {
                     Rename(folder, model.getFolder());
                 }
                 scope.Complete();
                 return(RedirectToAction("Index", new { parent = model.idTaiNguyen }));
             }
             catch (Exception e)
             {
                 ModelState.AddModelError("tenTaiNguyen", e.Message);
             }
     }
     return(View(model));
 }
        public System.Web.WebPages.HelperResult Traversal(TaiNguyen mode1)
        {
            return(new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 8 "..\..\Views\TaiNguyen\Delete.cshtml"

                if (mode1.laThuMuc)
                {
#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "        <p><span class=\"ui-icon ui-icon-folder-open\" style=\"display:inline-block\"" +
                                   "></span>");



#line 11 "..\..\Views\TaiNguyen\Delete.cshtml"
                    WriteTo(@__razor_helper_writer, mode1.getFolder());

#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "</p>\r\n");



#line 12 "..\..\Views\TaiNguyen\Delete.cshtml"
                }
                else
                {
#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "        <p><span class=\"ui-icon ui-icon-document\" style=\"display:inline-block\"></" +
                                   "span>");



#line 15 "..\..\Views\TaiNguyen\Delete.cshtml"
                    WriteTo(@__razor_helper_writer, mode1.getFolder());

#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "/");



#line 15 "..\..\Views\TaiNguyen\Delete.cshtml"
                    WriteTo(@__razor_helper_writer, mode1.tenTaiNguyen);

#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, " - ");



#line 15 "..\..\Views\TaiNguyen\Delete.cshtml"
                    WriteTo(@__razor_helper_writer, mode1.tepDinhKem);

#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "</p>\r\n");



#line 16 "..\..\Views\TaiNguyen\Delete.cshtml"
                }
                foreach (var tn in mode1.getChildren())
                {
                    if (tn.laThuMuc)
                    {
#line default
#line hidden


#line 21 "..\..\Views\TaiNguyen\Delete.cshtml"
                        WriteTo(@__razor_helper_writer, Traversal(tn));

#line default
#line hidden


#line 21 "..\..\Views\TaiNguyen\Delete.cshtml"
                    }
                }
                foreach (var tn in mode1.getChildren())
                {
                    if (!tn.laThuMuc)
                    {
#line default
#line hidden


#line 28 "..\..\Views\TaiNguyen\Delete.cshtml"
                        WriteTo(@__razor_helper_writer, Traversal(tn));

#line default
#line hidden


#line 28 "..\..\Views\TaiNguyen\Delete.cshtml"
                    }
                }

#line default
#line hidden
            }));
        }