public IActionResult Submit(EquipmentsPM pm) { if (!ModelState.IsValid) { return(BadRequest()); } pm.ReportingUser = UserId; pm.IP = Request.HttpContext.Connection.RemoteIpAddress?.ToString(); pm.SubmitDate = DateTime.Now; db.Save(pm); return(Ok()); }
public ActionResult <EquipmentsPM> New(string centerId) { var center = CommCenterController.GetItem(db, centerId); var user = GetUser(); var pm = new EquipmentsPM { CenterId = centerId }; if (user.AllowedEquipmentTypes.Contains(EquipmentType.Diesel)) { foreach (var eq in center.Diesels) { pm.DieselsPM.Add(new DieselPM(eq)); } } if (user.AllowedEquipmentTypes.Contains(EquipmentType.Rectifier)) { foreach (var eq in center.RectifierAndBatteries) { pm.RectifiersPM.Add(new RectifierPM(eq)); } } if (user.AllowedEquipmentTypes.Contains(EquipmentType.Battery)) { foreach (var eq in center.RectifierAndBatteries) { pm.BatteriesPM.Add(new BatteryPM(eq)); } } if (user.AllowedEquipmentTypes.Contains(EquipmentType.Compressor)) { foreach (var eq in center.Compressors) { pm.CompressorsPM.Add(new CompressorPM(eq)); } } if (user.AllowedEquipmentTypes.Contains(EquipmentType.GasCable)) { foreach (var eq in center.GasCables) { pm.GasCablesPM.Add(new GasCablePM(eq)); } } return(pm); }