/// <summary> /// Takes a list of <see cref="AssetIdentifier"/> pointing to a list of cashboxes and creates the model /// used to mass edit the list of cashboxes. The model contains only fields that can be changed for all /// items in the list. /// </summary> /// <param name="customerId">The customer id</param> /// <param name="cashboxIds">A <see cref="List{AssetIdentifier}"/> indicating cashboxes to be edited</param> /// <returns>An instance of <see cref="CashboxMassEditModel"/></returns> public CashboxMassEditModel GetMassEditModel(int customerId, List <AssetIdentifier> cashboxIds) { CashboxMassEditModel editModel = new CashboxMassEditModel() { CustomerId = customerId }; SetPropertiesOfAssetMassiveEditModel(editModel, cashboxIds); // Cashbox location editModel.LocationId = -1; editModel.Location = (from cbl in PemsEntities.CashBoxLocationTypes select new SelectListItemWrapper() { Selected = cbl.CashBoxLocationTypeId == editModel.LocationId, Text = cbl.CashBoxLocationTypeDesc, ValueInt = cbl.CashBoxLocationTypeId }).ToList(); editModel.Location.Insert(0, new SelectListItemWrapper() { Selected = editModel.LocationId == -1, Text = "", Value = "-1" }); // Preventative maintenance dates editModel.LastPrevMaint = (DateTime?)null; editModel.NextPrevMaint = (DateTime?)null; // Warantry expiration editModel.WarrantyExpiration = (DateTime?)null; return(editModel); }
/// <summary> /// Saves the updates of an instance of <see cref="CashboxMassEditModel"/> to the [AssetPending] table for each /// cashbox in the <see cref="CashboxMassEditModel.AssetIds"/> list. Only values that have been changed are /// stored. /// </summary> /// <param name="model">Instance of a <see cref="CashboxMassEditModel"/> with updates</param> public void SetMassEditModel(CashboxMassEditModel model) { var pendingFactory = new PendingFactory(ConnectionStringName, Now); foreach (var asset in model.AssetIds()) { // Save changes to the [AssetPending] table. pendingFactory.Save(model, model.CustomerId, asset.AreaId, (int)asset.AssetId); } }
/// <summary> /// Refreshes any lists in the <see cref="CashboxMassEditModel"/> instance. This is used /// where a model has been submitted from a web page but the contents of the dropdown lists were not passed back. /// </summary> /// <param name="editModel">The instance of the <see cref="CashboxMassEditModel"/> to refresh</param> public void RefreshMassEditModel(CashboxMassEditModel editModel) { // Get State list GetAssetStateList(editModel); // Cashbox location editModel.LocationId = -1; editModel.Location = (from cbl in PemsEntities.CashBoxLocationTypes select new SelectListItemWrapper() { Selected = cbl.CashBoxLocationTypeId == editModel.LocationId, Text = cbl.CashBoxLocationTypeDesc, ValueInt = cbl.CashBoxLocationTypeId }).ToList(); editModel.Location.Insert(0, new SelectListItemWrapper() { Selected = editModel.LocationId == -1, Text = "", Value = "-1" }); }