public async Task <ActionResult> EditEditEquipment(int?id, int equipmentid) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DailyWork dailyWork = await db.DailyWorks.FindAsync(id); if (dailyWork == null) { return(HttpNotFound()); } EquipmentUnit equipmentUnit = await db.EquipmentUnits.FindAsync(equipmentid); if (equipmentUnit == null) { return(HttpNotFound()); } var dailyWorkEquipmentData = new DailyWorkEquipmentData(); dailyWorkEquipmentData.DailyWork = dailyWork; dailyWorkEquipmentData.EquipmentUnit = equipmentUnit; dailyWorkEquipmentData.DailyWork.EquipmentUnits = dailyWorkEquipmentData.DailyWork.EquipmentUnits.OrderBy(p => p.ID).ToList(); ViewBag.WorkUnits = db.WorkUnits.Where(w => w.ProjectID == dailyWork.ProjectID && w.StartDate <= dailyWork.Date && (w.Complete == false || w.EndDate >= dailyWork.Date)).ToList(); return(View(dailyWorkEquipmentData)); }
public async Task <ActionResult> EditEditEquipment(int id, int equipmentid, DailyWorkEquipmentData dailyWorkEquipmentData) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { // db.Entry(materialBuyData).State = EntityState.Modified; DailyWork dailyWork = db.DailyWorks.FirstOrDefault(m => m.ID == dailyWorkEquipmentData.DailyWork.ID); EquipmentUnit equipmentUnit = await db.EquipmentUnits.FindAsync(equipmentid); if (equipmentUnit.NoteVn != dailyWorkEquipmentData.EquipmentUnit.NoteVn) { equipmentUnit.Translate = false; } equipmentUnit.Date = (DateTime)dailyWorkEquipmentData.DailyWork.Date; equipmentUnit.DailyWorkID = dailyWorkEquipmentData.DailyWork.ID; equipmentUnit.NameKr = dailyWorkEquipmentData.EquipmentUnit.NameKr; equipmentUnit.NameVn = dailyWorkEquipmentData.EquipmentUnit.NameVn; equipmentUnit.NoteVn = dailyWorkEquipmentData.EquipmentUnit.NoteVn; equipmentUnit.NoteKr = dailyWorkEquipmentData.EquipmentUnit.NoteKr; equipmentUnit.EquipCount = dailyWorkEquipmentData.EquipmentUnit.EquipCount; await db.SaveChangesAsync(); return(RedirectToAction("EditAddEquipment", new { id = dailyWorkEquipmentData.DailyWork.ID })); } return(View(dailyWorkEquipmentData)); }
/// <summary> /// Creates and ataches new equipment, from selected prefab, to a ship. /// </summary> /// <param name="eUnit"> /// A <see cref="EquipmentUnit"/> of equipment that need to be mounted. /// </param> /// <returns> /// A <see cref="EquipmentUnit"/> that was created and mounted, or null if failed. /// </returns> public EquipmentUnit MountEquipment(EquipmentUnit eUnit) { if (eUnit.equipmentProperties.type == type) { EquipmentUnit newEUnit = (EquipmentUnit)GameObject.Instantiate (eUnit); switch (type) { case EquipmentType.Weapon: break; case EquipmentType.Hull: break; case EquipmentType.Engine: break; case EquipmentType.Misc: break; } newEUnit.equipmentProperties.mySlot = this; newEUnit.transform.parent = getLevelProperties ().playerController.ship.transform; mountedEquipmentUnit = newEUnit; mountedEquipmentUnit.parentMotor = getLevelProperties ().playerController.shipMotor; // linkToCell.renderer.material = eUnit.equipmentProperties.icon; return mountedEquipmentUnit; } else { return null; } }
public async Task <ActionResult> EditAddEquipment(DailyWorkEquipmentData dailyWorkEquipmentData) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { // db.Entry(materialBuyData).State = EntityState.Modified; DailyWork dailyWork = db.DailyWorks.FirstOrDefault(m => m.ID == dailyWorkEquipmentData.DailyWork.ID); dailyWorkEquipmentData.EquipmentUnit.DailyWorkID = dailyWorkEquipmentData.DailyWork.ID; dailyWorkEquipmentData.EquipmentUnit.Date = (DateTime)dailyWorkEquipmentData.DailyWork.Date; EquipmentUnit equipTemp = db.EquipmentUnits.FirstOrDefault(e => e.NameVn.Equals(dailyWorkEquipmentData.EquipmentUnit.NameVn)); if (equipTemp != null) { dailyWorkEquipmentData.EquipmentUnit.NameKr = equipTemp.NameKr; if (dailyWorkEquipmentData.EquipmentUnit.NoteVn == null) { dailyWorkEquipmentData.EquipmentUnit.Translate = equipTemp.Translate; } } db.EquipmentUnits.Add(dailyWorkEquipmentData.EquipmentUnit); dailyWork.EquipmentUnits.Add(dailyWorkEquipmentData.EquipmentUnit); await db.SaveChangesAsync(); return(RedirectToAction("EditAddEquipment", new { id = dailyWorkEquipmentData.DailyWork.ID })); } return(View(dailyWorkEquipmentData)); }
public void Delete(EquipmentUnit equipmentUnit) { if (equipmentUnit is null) { throw new ArgumentException(); } _equipmentUnitRepository.Repository.Delete(equipmentUnit); }
public EquipmentUnit Update(EquipmentUnit equipmentUnit) { if (equipmentUnit is null) { throw new ArgumentException(); } return(_equipmentUnitRepository.Repository.Update(equipmentUnit)); }
public async Task <ActionResult> DeleteConfirmed(int id) { EquipmentUnit equipmentUnit = await db.EquipmentUnits.FindAsync(id); db.EquipmentUnits.Remove(equipmentUnit); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteEquipment(int id, int equipmentid) { EquipmentUnit equipmentUnit = await db.EquipmentUnits.FindAsync(equipmentid); db.EquipmentUnits.Remove(equipmentUnit); //PreDeleteUnit(id, paymentid); await db.SaveChangesAsync(); return(RedirectToAction("EditAddEquipment", new { id = id })); }
public EquipmentUnit Create(EquipmentUnit equipmentUnit) { if (equipmentUnit is null) { throw new ArgumentException(); } if (!_equipmentTypeRepository.Repository.ExistsByID(equipmentUnit.EquipmentType.Id)) { equipmentUnit.EquipmentType = _equipmentTypeRepository.Repository.Create(equipmentUnit.EquipmentType); } return(_equipmentUnitRepository.Repository.Create(equipmentUnit)); }
public async Task <ActionResult> Edit([Bind(Include = "ID,DailyWorkID,Date,NameVn,NameKr,NoteVn,NoteKr,EquipCount,Translate")] EquipmentUnit equipmentUnit) { if (ModelState.IsValid) { db.Entry(equipmentUnit).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index", new { translate = Session["Translate"] })); } ViewBag.DailyWorkID = new SelectList(db.DailyWorks, "ID", "WeatherVn", equipmentUnit.DailyWorkID); return(View(equipmentUnit)); }
public async Task <ActionResult> Create([Bind(Include = "ID,DailyWorkID,Date,NameVn,NameKr,NoteVn,NoteKr,EquipCount,Translate")] EquipmentUnit equipmentUnit) { if (ModelState.IsValid) { db.EquipmentUnits.Add(equipmentUnit); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.DailyWorkID = new SelectList(db.DailyWorks, "ID", "WeatherVn", equipmentUnit.DailyWorkID); return(View(equipmentUnit)); }
// GET: EquipmentUnit/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EquipmentUnit equipmentUnit = await db.EquipmentUnits.FindAsync(id); if (equipmentUnit == null) { return(HttpNotFound()); } return(View(equipmentUnit)); }
// GET: EquipmentUnit/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EquipmentUnit equipmentUnit = await db.EquipmentUnits.FindAsync(id); if (equipmentUnit == null) { return(HttpNotFound()); } ViewBag.DailyWorkID = new SelectList(db.DailyWorks, "ID", "WeatherVn", equipmentUnit.DailyWorkID); return(View(equipmentUnit)); }