public async Task <ActionResult> Edit(
            [Bind(Include = "Id,Name,Nature,Description,Group,SequenceType,MultisequenceId,MultisequenceNumber,CollectionCountry,CollectionDate")] Matter matter)
        {
            using (var db = new LibiadaWebEntities())
            {
                if (ModelState.IsValid)
                {
                    db.Entry(matter).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }

                var data = new Dictionary <string, object>
                {
                    { "natures", EnumHelper.GetSelectList(typeof(Nature), matter.Nature) },
                    { "groups", EnumExtensions.ToArray <Group>().ToSelectListWithNature() },
                    { "sequenceTypes", EnumExtensions.ToArray <SequenceType>().ToSelectListWithNature() },
                    { "sequencesCount", db.CommonSequence.Count(c => c.MatterId == matter.Id) },
                    { "matter", matter },
                    { "multisequences", db.Multisequence.ToList() },
                    { "nature", ((byte)matter.Nature).ToString() },
                    { "group", ((byte)matter.Group).ToString() },
                    { "sequenceType", ((byte)matter.SequenceType).ToString() }
                };

                ViewBag.data = JsonConvert.SerializeObject(data);
                return(View(matter));
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Nature,SequenceGroupType")] SequenceGroup sequenceGroup, long[] matterIds)
        {
            if (ModelState.IsValid)
            {
                sequenceGroup.CreatorId  = AccountHelper.GetUserId();
                sequenceGroup.ModifierId = AccountHelper.GetUserId();
                var matters = db.Matter.Where(m => matterIds.Contains(m.Id)).ToArray();
                foreach (var matter in matters)
                {
                    sequenceGroup.Matters.Add(matter);
                }

                db.SequenceGroup.Add(sequenceGroup);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(sequenceGroup));
        }
        public async Task <ActionResult> DeleteConfirmed(long id)
        {
            using (var db = new LibiadaWebEntities())
            {
                CommonSequence commonSequence = await db.CommonSequence.FindAsync(id);

                db.CommonSequence.Remove(commonSequence);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult> DeleteConfirmed(long id)
        {
            using (var db = new LibiadaWebEntities())
            {
                Matter matter = await db.Matter.FindAsync(id);

                db.Matter.Remove(matter);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Notation,MatterId,RemoteDb,RemoteId,Description")] CommonSequence commonSequence)
        {
            using (var db = new LibiadaWebEntities())
            {
                if (ModelState.IsValid)
                {
                    db.Entry(commonSequence).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }

                ViewBag.MatterId = new SelectList(Cache.GetInstance().Matters.ToArray(), "Id", "Name", commonSequence.MatterId);
                ViewBag.Notation = EnumHelper.GetSelectList(typeof(Notation), commonSequence.Notation);
                ViewBag.RemoteDb = EnumHelper.GetSelectList(typeof(RemoteDb), commonSequence.RemoteDb);
                return(View(commonSequence));
            }
        }