Beispiel #1
0
        public void MarkAsResistanceNews(int newsId)
        {
            var news = _db.News.Where(n => n.Id == newsId).FirstOrDefault();

            news.Status           = COMMON.Constants.Enums.Status.Linked;
            _db.Entry(news).State = EntityState.Modified;
            _db.SaveChanges();
        }
Beispiel #2
0
        public IActionResult Save(ProtestoType model)
        {
            var protestoType = db.ProtestoType.Find(model.Id);

            protestoType.Name            = model.Name;
            db.Entry(protestoType).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(Ok());
        }
        public IActionResult Save(Corporation model)
        {
            var corporation = db.Corporation.Find(model.Id);

            corporation.Name            = model.Name;
            db.Entry(corporation).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(Ok());
        }
        public IActionResult Save(ResistanceReason model)
        {
            var resistanceReason = db.ResistanceReason.Find(model.Id);

            resistanceReason.Name            = model.Name;
            db.Entry(resistanceReason).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(Ok());
        }
        public void DeleteProtesto(ProtestoDeleteModel model)
        {
            var protesto = _db.Protesto.Find(model.ProtestoId);

            protesto.Updater = model.UserName;
            protesto.Deleted = true;
            var res = _db.Resistance.FirstOrDefault(s => s.Id == protesto.ResistanceId);
            var minProtestoStartDate = _db.Protesto.Where(x => !x.Deleted && x.Id != model.ProtestoId && x.ResistanceId == res.Id).Select(s => s.StartDate);

            res.StartDate = !minProtestoStartDate.Any() ? default(DateTime): minProtestoStartDate.Min();
            _db.Resistance.Update(res);
            _db.Entry(protesto).State = EntityState.Modified;
            _db.SaveChanges();
        }
Beispiel #6
0
        public IActionResult ReplaceCompany(ReplaceModel model)
        {
            var usedResistances = db.Resistance.Where(s => s.CompanyId == model.Id).ToList();

            foreach (var item in usedResistances)
            {
                item.CompanyId       = model.NewId;
                db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            }
            var company = db.Company.Find(model.Id);

            company.Deleted = true;
            db.SaveChanges();
            return(Ok());
        }
Beispiel #7
0
        public IActionResult ReplaceTradeUnion(ReplaceModel model)
        {
            var usedResistances = db.Resistance.Where(s => s.TradeUnionId == model.Id).ToList();

            foreach (var item in usedResistances)
            {
                item.TradeUnionId    = model.NewId;
                db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            }
            var tradeUnion = db.TradeUnion.Find(model.Id);

            db.TradeUnion.Remove(tradeUnion);
            db.SaveChanges();
            return(Ok());
        }