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
        public bool DeleteModels(int id)
        {
            bool result = false;

            try
            {
                AssetManager_Models model = _context.AssetManager_Models.FirstOrDefault(x => x.Id == id);
                _context.AssetManager_Models.Remove(model);
                _context.SaveChanges();
                result = true;
                _logger.Info("Model with id " + id + " was deleted.");
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            return(result);
        }
Beispiel #3
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 #4
0
        public int EditModel(int id, AssetManager_Models model)
        {
            AssetManager_Models oldModel = _context.AssetManager_Models.FirstOrDefault(x => x.Id == id);

            try
            {
                if (oldModel != null)
                {
                    oldModel.CompanyId           = model.CompanyId;
                    oldModel.DescriptionNotes    = model.DescriptionNotes;
                    oldModel.ManufacturerWebsite = model.ManufacturerWebsite;
                    oldModel.ModelName           = model.ModelName;
                    oldModel.SupportWebsite      = model.SupportWebsite;
                }
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            return(model.Id);
        }
Beispiel #5
0
 public int CreateModel(AssetManager_Models model)
 {
     _context.AssetManager_Models.Add(model);
     _context.SaveChanges();
     return(model.Id);
 }