Beispiel #1
0
        private AssetManager_Models mapViewModelToEntityModel(AssetManager_Models_vm VMModel)
        {
            var models = new AssetManager_Models
            {
                Id                  = VMModel.Id,
                ModelName           = VMModel.ModelName,
                CompanyId           = VMModel.CompanyId,
                DescriptionNotes    = VMModel.DescriptionNotes,
                ManufacturerWebsite = VMModel.ManufacturerWebsite,
                SupportWebsite      = VMModel.SupportWebsite
            };

            return(models);
        }
Beispiel #2
0
        private AssetManager_Models_vm mapEntityToViewModel(AssetManager_Models EFModel)
        {
            _logger.Debug("Mapping Entity to Model View Model.");
            var vmM = new AssetManager_Models_vm
            {
                Id                     = EFModel.Id,
                ModelName              = EFModel.ModelName,
                CompanyId              = EFModel.CompanyId,
                CompanyName            = EFModel.AssetManager_Companies != null ? EFModel.AssetManager_Companies.Name : "",
                DescriptionNotes       = EFModel.DescriptionNotes,
                ManufacturerWebsite    = EFModel.ManufacturerWebsite,
                SupportWebsite         = EFModel.SupportWebsite,
                AssetManager_Companies = new AssetManager_Models_Company
                {
                    CompanyId   = EFModel.CompanyId,
                    CompanyName = EFModel.AssetManager_Companies != null ? EFModel.AssetManager_Companies.Name : ""
                }
            };

            return(vmM);
        }
Beispiel #3
0
 public int EditModelById(int id, AssetManager_Models_vm model)
 {
     return(_assetManagerModelsRepository.EditModel(id, mapViewModelToEntityModel(model)));
 }
Beispiel #4
0
 public int CreateModel(AssetManager_Models_vm model)
 {
     return(_assetManagerModelsRepository.CreateModel(mapViewModelToEntityModel(model)));
 }
Beispiel #5
0
 /// <summary>
 /// Puts the specified identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Put(int id, [FromBody] AssetManager_Models_vm value)
 {
     _logger.Info("Editing the model with id " + id);
     return(_assetModelsManager.EditModelById(id, value));
 }
Beispiel #6
0
 /// <summary>
 /// Posts the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Post([FromBody] AssetManager_Models_vm value)
 {
     _logger.Info("Creating a new model.");
     return(_assetModelsManager.CreateModel(value));
 }