Пример #1
0
        public ActionResult Edit([Bind(Include = "ResumeSectionId, Entry, SelectedTags")] ResumeEntryVm resumeEntry, int resumeSectionId)
        {
            var item = db.ResumeEntry.Find(resumeEntry.Entry.Id);

            item.Role            = resumeEntry.Entry.Role;
            item.Establishment   = resumeEntry.Entry.Establishment;
            item.Additional      = resumeEntry.Entry.Additional;
            item.Description     = resumeEntry.Entry.Description;
            item.StartDate       = resumeEntry.Entry.StartDate;
            item.EndDate         = resumeEntry.Entry.EndDate;
            item.CurrentPosition = resumeEntry.Entry.CurrentPosition;
            item.ResumeSectionId = resumeSectionId;
            item.Sorter          = resumeEntry.Entry.Sorter;
            item.ResumeTag.Clear();
            foreach (var ti in resumeEntry.SelectedTags)
            {
                if (!item.ResumeTag.Any(t => t.Id == ti))
                {
                    item.ResumeTag.Add(db.ResumeTag.Find(ti));
                }
            }


            db.Entry(item).State = EntityState.Modified;
            if (ModelState.IsValid)
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ResumeSectionId = new SelectList(db.ResumeSection, "Id", "ContentHeader", resumeEntry.Entry.ResumeSectionId);
            return(View(resumeEntry));
        }
Пример #2
0
 public ActionResult Create([Bind(Include = "ResumeSectionId, Entry, SelectedTags")] ResumeEntryVm resumeEntry, int resumeSectionId)
 {
     if (ModelState.IsValid)
     {
         if (resumeEntry.Entry.StartDate == resumeEntry.Entry.EndDate)
         {
             resumeEntry.Entry.StartDate = null;
             resumeEntry.Entry.EndDate   = null;
         }
         if (resumeEntry.Entry.CurrentPosition)
         {
             resumeEntry.Entry.EndDate = new DateTime();
         }
         resumeEntry.Entry.ResumeSectionId = resumeSectionId;
         resumeEntry.Entry.ResumeSection   = db.ResumeSection.Find(resumeSectionId);
         foreach (var ti in resumeEntry.SelectedTags)
         {
             resumeEntry.Entry.ResumeTag.Add(db.ResumeTag.Find(ti));
         }
         db.ResumeEntry.Add(resumeEntry.Entry);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ResumeSectionId = new SelectList(db.ResumeSection, "Id", "ContentHeader", resumeEntry.Entry.ResumeSectionId);
     return(View(resumeEntry));
 }
Пример #3
0
        // GET: ResumeEntries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ResumeEntryVm Vm = new ResumeEntryVm
            {
                Entry = db.ResumeEntry.Include(o => o.ResumeTag).Single(r => r.Id == id)
            };

            if (Vm.Entry == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var alltags = db.ResumeTag.ToList();

            Vm.Tags = alltags.Select(o => new SelectListItem
            {
                Text  = o.Tag,
                Value = o.Id.ToString()
            });

            ViewBag.ResumeSectionId = new SelectList(db.ResumeSection, "Id", "ContentHeader", Vm.Entry.ResumeSectionId);
            //resumeEntry.ResumeTag = (from o in db.ResumeTag where o.ResumeEntry == resumeEntry select o).ToList();
            return(View(Vm));
        }