예제 #1
0
 public ActionResult AddBlog([FromBody] BlogTable blog, [FromQuery] string tenantId)
 {
     blog.SetTenant(tenantId);
     _db.Blogs.Add(blog);
     _db.SaveChanges();
     return(Ok());
 }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            BlogTable blogTable = db.BlogTables.Find(id);

            db.BlogTables.Remove(blogTable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(long id)
        {
            db.Database.CommandTimeout = 50;
            BlogTable blogTable = db.BlogTable.Find(id);

            db.BlogTable.Remove(blogTable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
 public ActionResult BlogEntry(BlogTable obj)
 {
     {
         KamayaniDBEntities2 obj2 = new KamayaniDBEntities2();
         obj2.BlogTables.Add(obj);
         obj2.SaveChanges();
         return(RedirectToAction("Recipes", "Recipes"));
     }
 }
예제 #5
0
 public ActionResult Recipes(BlogTable obj)
 {
     {
         KamayaniDBEntities2 obj2 = new KamayaniDBEntities2();
         obj2.BlogTables.Add(obj);
         obj2.SaveChanges();
         return(View());
     }
 }
 public ActionResult Edit([Bind(Include = "id,Blog,Date,Category,Heading,ShortDiscription,FeaturedImage")] BlogTable blogTable)
 {
     db.Database.CommandTimeout = 50;
     if (ModelState.IsValid)
     {
         db.Entry(blogTable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(blogTable));
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "MaBlog,TenBlog,NoiDung,NgayDang,MaNguoiDung,AnhMinhHoa,MaTheLoai")] BlogTable blogTable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blogTable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaTheLoai = new SelectList(db.TheLoaiTables, "MaTheLoai", "TheLoai", blogTable.MaTheLoai);
     return(View(blogTable));
 }
예제 #8
0
        // GET: BlogTables/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogTable blogTable = db.BlogTables.Find(id);

            if (blogTable == null)
            {
                return(HttpNotFound());
            }
            return(View(blogTable));
        }
예제 #9
0
        // GET: BlogTables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogTable blogTable = db.BlogTables.Find(id);

            if (blogTable == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaTheLoai = new SelectList(db.TheLoaiTables, "MaTheLoai", "TheLoai", blogTable.MaTheLoai);
            return(View(blogTable));
        }
예제 #10
0
        public async Task <IActionResult> Create([Bind("BlogId,BlogHeadline,BlogEntry,BlogDateTime,CatId")]
                                                 BlogTable blogTable)
        {
            if (ModelState.IsValid)
            {
                blogTable.BlogDateTime = DateTime.Now;
                _context.Add(blogTable);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["CatId"] = new SelectList(_context.Categories, "CatId", "CatName", blogTable.CatId);
            return(View(blogTable));
        }
        // GET: Blog/Details/5
        public ActionResult Details(long?id)
        {
            db.Database.CommandTimeout = 50;
            ViewBag.header             = "Blog Details";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogTable blogTable = db.BlogTable.Find(id);

            if (blogTable == null)
            {
                return(HttpNotFound());
            }
            return(View(blogTable));
        }
        public ActionResult blog_Details(long?id)
        {
            //var id = RouteData.Values["id"].ToString();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogTable blogTable = db.BlogTable.Find(id);

            if (blogTable == null)
            {
                return(HttpNotFound());
            }
            db.Database.CommandTimeout = 50;
            ViewBag.bloglist           = db.BlogTable.ToList();
            return(View(blogTable));
        }
        // GET: Blog/Edit/5
        public ActionResult Edit(long?id)
        {
            db.Database.CommandTimeout = 50;
            ViewBag.header             = "Edit Blog";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogTable blogTable = db.BlogTable.Find(id);

            if (blogTable == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Featuredimage = blogTable.FeaturedImage;
            return(View(blogTable));
        }
예제 #14
0
        public static bool IsBlogTableEqualAfterConvertFromBlogForCreatingDto(
            this BlogTable blog1,
            BlogTable blog2)
        {
            if (blog1.Id == blog2.Id)
            {
                throw new Exception("Blog 'Id' should be 0.");
            }
            if (blog1.Title != blog2.Title)
            {
                throw new Exception("Blog 'Title' are not Equal.");
            }
            if (blog1.Slug != blog2.Slug)
            {
                throw new Exception("Blog 'Slug' are not Equal.");
            }
            if (blog1.IsPublished != blog2.IsPublished)
            {
                throw new Exception("Blog 'IsPublished' are not Equal.");
            }
            if (blog1.PublishedDate != blog2.PublishedDate)
            {
                throw new Exception("Blog 'PublishedDate' are not Equal.");
            }
            if (blog1.Description != blog2.Description)
            {
                throw new Exception("Blog 'Description' are not Equal.");
            }
            if (blog1.Body != blog2.Body)
            {
                throw new Exception("Blog 'Body' are not Equal.");
            }
            if (blog1.Tags != blog2.Tags)
            {
                throw new Exception("Blog 'Tags' are not Equal.");
            }
            if (blog1.KeyWords != blog2.KeyWords)
            {
                throw new Exception("Blog 'Key Words' are not Equal.");
            }

            return(true);
        }
예제 #15
0
        public BaseResponse WriteBlog(BlogTable bTable, string userId)
        {
            var result = new BaseResponse();

            try
            {
                var internalUserId = _context.UserTable.Where(x => x.AspNetUserId == userId).Single().Id;
                bTable.UserId = internalUserId;
                _context.BlogTable.Add(bTable);
                _context.SaveChanges();
                result.Message = "Ok";
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
예제 #16
0
        public HttpResponseMessage PutUpdateBlog([FromBody] BlogTable obj)
        {
            using (BLogDatabaseEntities context = new BLogDatabaseEntities())
            {
                try
                {
                    var entity = context.BlogTables.FirstOrDefault(x => x.BlogId == obj.BlogId);
                    if (entity == null)
                    {
                        ErrorLog eo = new ErrorLog()
                        {
                            ErrorMessage = "Edit - Requested Blog_id " + obj.BlogId + " not found!", Severity = "medium"
                        };
                        context.ErrorLogs.Add(eo);
                        context.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.NotFound, "Blog_ID : " + obj.BlogId + " Not Found"));
                    }
                    else
                    {
                        entity.BlogTitle    = obj.BlogTitle;
                        entity.Content      = obj.Content;
                        entity.LastModified = DateTime.Now;
                        context.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.OK, "Blog_ID : " + obj.BlogId + " Updated"));
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog eo = new ErrorLog()
                    {
                        ErrorMessage = "Editing Blog Failed with error -  " + ex, Severity = "low"
                    };
                    context.ErrorLogs.Add(eo);
                    context.SaveChanges();

                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
                }
            }
        }
예제 #17
0
        public HttpResponseMessage PostNewBlog([FromBody] BlogTable obj)
        {
            using (BLogDatabaseEntities context = new BLogDatabaseEntities())
            {
                try
                {
                    context.BlogTables.Add(obj);
                    context.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.Created, "Added Blog_ID : " + obj.BlogId + " Blog_Title : " + obj.BlogTitle));
                }
                catch (Exception ex)
                {
                    ErrorLog eo = new ErrorLog()
                    {
                        ErrorMessage = "Adding Blog Failed with error -  " + ex, Severity = "low"
                    };
                    context.ErrorLogs.Add(eo);
                    context.SaveChanges();

                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Please provide blog details to add."));
                }
            }
        }