Beispiel #1
0
        public async Task <ActionResult> AnnouncementDataCreate(AnnouncementDataModel announcementDataModel, string sessionid)
        {
            ViewBag.SessionID = sessionid;
            if (Authenticate("AnnouncementDataCreate"))
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        announcementDataModel.date = DateTime.Now.Date;
                        announcementDataDbContext.AnnouncementDataDbSet.Add(announcementDataModel);
                        await announcementDataDbContext.SaveChangesAsync();

                        return(RedirectToAction("AnnouncementDataIndex", new { sessionid = ViewBag.SessionID }));
                    }
                }
                catch
                {
                    Response.Write("<script>alert('Server Error!!');</script>");
                    ViewBag.errormssg = "Server Error!!";
                }
                return(View(announcementDataModel));
            }
            return(Redirect(new Uri(Request.Url, Url.Action("AuthenticationError", "Error", new { sessionid = ViewBag.SessionID })).ToString()));
        }
Beispiel #2
0
        public async Task <ActionResult> AnnouncementDataEdit(string sessionid, int?id)
        {
            ViewBag.SessionID = sessionid;
            if (Authenticate("AnnouncementDataEdit"))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                AnnouncementDataModel announcementDataModel = await announcementDataDbContext.AnnouncementDataDbSet.FindAsync(id);

                if (announcementDataModel == null)
                {
                    return(HttpNotFound());
                }
                return(View(announcementDataModel));
            }
            return(Redirect(new Uri(Request.Url, Url.Action("AuthenticationError", "Error", new { sessionid = ViewBag.SessionID })).ToString()));
        }
Beispiel #3
0
        public async Task <JsonResult> AnnouncementDataDelete(string sessionid, int?id)
        {
            ViewBag.SessionID = sessionid;
            if (Authenticate("ProjectDataDelete"))
            {
                try
                {
                    if (id != null)
                    {
                        AnnouncementDataModel announcementDataModel = await announcementDataDbContext.AnnouncementDataDbSet.FindAsync(id);

                        announcementDataDbContext.AnnouncementDataDbSet.Remove(announcementDataModel);
                        await announcementDataDbContext.SaveChangesAsync();

                        return(Json("success"));
                    }
                }
                catch
                {
                    return(Json("Fail"));
                }
            }
            return(Json("Fail"));
        }