public ActionResult DeleteConfirmed(int id)
        {
            Announcment announcment = db.Announcments.Find(id);

            db.Announcments.Remove(announcment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,Header,Body,ExpirationDate")] Announcment announcment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(announcment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(announcment));
 }
        public ActionResult Create([Bind(Include = "Id,Name,Header,Body,ExpirationDate")] Announcment announcment)
        {
            if (ModelState.IsValid)
            {
                db.Announcments.Add(announcment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(announcment));
        }
        // GET: Announcments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Announcment announcment = db.Announcments.Find(id);

            if (announcment == null)
            {
                return(HttpNotFound());
            }
            return(View(announcment));
        }
        public ActionResult ViewedAnnouncment(int?announcmentId)
        {
            var         userId = User.Identity.GetUserId();
            FuneralHome home   = db.FuneralHomes.Where(h => h.UserId == userId).FirstOrDefault();

            if (home.Setting != null)
            {
                Announcment a = db.Announcments.Find(announcmentId);
                if (a != null)
                {
                    List <Announcment> announcments = new List <Announcment>();
                    if (home.AnnouncmentsViewed != null)
                    {
                        announcments = home.AnnouncmentsViewed;
                    }
                    announcments.Add(a);
                    home.AnnouncmentsViewed = announcments;
                    db.Entry(home).State    = EntityState.Modified;
                    db.SaveChanges();
                    return(Json(new { success = "true" }));
                }
            }
            return(Json(new { success = "false" }));
        }
Exemplo n.º 6
0
        public void CreateAnnoucment(AnnouncmentsInsertDto input)
        {
            var list          = new List <Announcment>();
            var announcmentId = Guid.NewGuid();

            foreach (var annoucment in input.Announcments)
            {
                var ann = new Announcment();
                //ann.Id = Guid.NewGuid();
                ann.Subject           = annoucment.Subject;
                ann.PrimaryCategory   = annoucment.PrimaryCategory;
                ann.SecondaryCategory = annoucment.SecondaryCategory;
                ann.Message           = annoucment.Message;
                ann.LanguageId        = annoucment.LanguageId;
                ann.AnnouncmentId     = announcmentId;
                list.Add(ann);
            }
            var announcmentList = list.MapTo <List <Announcment> >();

            foreach (var announcment in announcmentList)
            {
                _announcmentRepository.Insert(announcment);
            }
        }