Пример #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            UnitRelations unitRelations = _dbContext.UnitRelations.Find(id);

            _dbContext.UnitRelations.Remove(unitRelations);
            _dbContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,BigUnitId,SmallUnitId,RelationNumber,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy,IsActive")] UnitRelations unitRelations)
 {
     if (ModelState.IsValid)
     {
         _dbContext.Entry(unitRelations).State = EntityState.Modified;
         _dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(unitRelations));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "Id,BigUnitId,SmallUnitId,RelationNumber")] UnitRelations unitRelations)
        {
            if (ModelState.IsValid)
            {
                unitRelations.Id = Guid.NewGuid();
                _dbContext.UnitRelations.Add(unitRelations);
                _dbContext.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(unitRelations));
        }
Пример #4
0
        public ActionResult Index()
        {
            var units = _dbContext.UnitRelations.ToList();

            foreach (var unit in units)
            {
                var           bigUnitId     = _dbContext.Units.Where(x => x.Id == unit.BigUnitId).FirstOrDefault();
                UnitRelations unitRelations = new UnitRelations();
                ViewBag.BigUnitName = bigUnitId.Name;
            }

            return(View(units));
        }
Пример #5
0
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UnitRelations unitRelations = _dbContext.UnitRelations.Find(id);

            if (unitRelations == null)
            {
                return(HttpNotFound());
            }
            return(View(unitRelations));
        }