Exemplo n.º 1
0
        public IActionResult DeleteCentury(CenturyViewModel model)
        {
            bool status = false;
            var  x      = _db.Century.FirstOrDefault(a => a.Centuries.Equals(model.Centuries));

            if (x != null)
            {
                _db.Century.Remove(x);
                _db.SaveChanges();
                status = true;
            }
            return(Json(status));
        }
Exemplo n.º 2
0
        public IActionResult UpdateCentury(CenturyViewModel model)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                var century = _db.Century.FirstOrDefault(x => x.Centuries.Equals(model.Centuries));
                using (var memoryStream = new MemoryStream())
                {
                    model.Data.CopyTo(memoryStream);
                    century.Data = memoryStream.ToArray();
                }
                _db.SaveChanges();
                status = true;
            }
            return(Json(status));
        }
Exemplo n.º 3
0
        public IActionResult AddCentury(CenturyViewModel model)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                var century = new Century();
                century.Centuries = model.Centuries;
                using (var memoryStream = new MemoryStream())
                {
                    model.Data.CopyTo(memoryStream);
                    century.Data = memoryStream.ToArray();
                }
                _db.Century.Add(century);
                _db.SaveChanges();
                status = true;
            }
            return(Json(status));
        }