Exemple #1
0
        public async Task <IActionResult> CreateTextfile([Bind("Id,Title, Uri, Content, Name, ReadOnly,ParentPath")]
                                                         ItemTextFile file, string returnUrl)
        {
            BookmarkEntity parent = folderRepo.GetById((Convert.ToInt32(file.ParentPath)));

            if (file.ParentPath.Equals("-1"))
            {
                file.ParentPath = "Root";
            }
            else
            {
                if (parent == null)
                {
                    return(NotFound());
                }
                file.ParentPath = parent.ToString().Replace("/", "|");
            }

            if (ModelState.IsValid)
            {
                if (parent.ReadOnly)
                {
                    return(View("Error", new ErrorViewModel("Parent folder is not Editable!", "\'" + file.ParentPath + "\' is readonly")));
                }
                if (bookmarkEntityRepo.NameExistById(file.Name, file.ParentPath, file.Id))
                {
                    return(View("Error", new ErrorViewModel()));
                }
                itemTextfileRepo.InsertAsync(file);
                await _context.SaveChangesAsync();

                if (returnUrl != null && returnUrl.Equals("Home"))
                {
                    return(Redirect("/Home"));
                }
                else
                {
                    return(Redirect("/BookmarkEntities"));
                }
            }
            return(View(file));
        }
Exemple #2
0
 public void Update(ItemTextFile Obj)
 {
     db.Entry(Obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
 }
Exemple #3
0
 public async void InsertAsync(ItemTextFile Obj)
 {
     await db.ItemTextFile.AddAsync(Obj);
 }