Esempio n. 1
0
        public bool EditTheory(TheoryEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Theories.FirstOrDefault(p => p.OwnerId == _userId && p.TheoryId == model.TheoryId);

                entity.Subject     = model.Subject;
                entity.Content     = model.Content;
                entity.DateCreated = DateTimeOffset.Now;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult EditTheory(TheoryEdit model)
        {
            var service = CreateResourceService();

            if (service.UpdateResource(model))
            {
                TempData["SaveResult"] = "Resource was successfully updated.";
                return(RedirectToAction("Detail", new { id = model.ResourceId }));
            }
            else
            {
                TempData["ErrorMessage"] = "Resource could not be updated. Try again later.";
                return(RedirectToAction("Detail", new { id = model.ResourceId }));
            }
        }
        private void UpdateTheoryResourceEntity(TheoryEdit model, TheoryResource entity, out bool wasFileChanged)
        {
            wasFileChanged        = false;
            entity.Title          = model.Title;
            entity.Description    = model.Description;
            entity.DateModified   = DateTimeOffset.Now;
            entity.IsDownloadable = model.IsDownloadable;
            entity.IsPublic       = model.IsPublic;
            entity.Topic          = model.Topic;
            entity.GradeLevel     = model.GradeLevel;

            if (model.File != null)
            {
                entity.File    = _fileHelper.BuildResourceFile(model.File);
                wasFileChanged = true;
            }
        }