Пример #1
0
 private List<Bay> BayMaker(Row row, MappingViewModel mapItem)
 {
     List<Bay> bays = new List<Bay>();
     for (int i = 0; i < mapItem.countHolder; i++)
     {
         Bay bay = new Bay { rowID = row.rowID, bayNumber = i + 1 };
         bays.Add(bay);
     }
     return bays;
 }
Пример #2
0
 public async Task<ActionResult> AddBays(int? id, MappingViewModel mvm)
 {
     if (id == null)
         RedirectToAction("SelectBuilding");
     Row row = db.Row.Find(id);
     row.numberOfBays = mvm.row.numberOfBays;
     List<Bay> bays = new List<Bay>();
     for (int i = 0; i < mvm.row.numberOfBays; i++)
     {
         Bay bay = new Bay { bayNumber = i + 1, Row = row };
         if (ModelState.IsValid)
         {
             db.Bay.Add(bay);
             await db.SaveChangesAsync();
         }
     }
     return RedirectToAction("BuildingDetail", new { id = row.BuildingID });
 }