Пример #1
0
        public int Create(PalletDescriptor palletDescriptorToCreate)
        {
            if (palletDescriptorToCreate == null)
            {
                throw new Exception("The Pallet Descriptor sent in for creation is null.");
            }

            base.UpdateDateAdded(palletDescriptorToCreate);
            base.UpdateIsDeletedToFalse(palletDescriptorToCreate);

            db.PalletDescriptors.Add(palletDescriptorToCreate);
            db.SaveChanges();
            int idOfPalletDescriptor = palletDescriptorToCreate.ID;

            return idOfPalletDescriptor;
        }
Пример #2
0
 public void Destroy(PalletDescriptor palletDescriptorToDestroy)
 {
     Destroy(palletDescriptorToDestroy.ID);
 }
Пример #3
0
 public void Delete(PalletDescriptor palletDescriptorToDelete)
 {
     Delete(palletDescriptorToDelete.ID);
 }
Пример #4
0
        public int Update(PalletDescriptor updatedPalletDescriptor)
        {
            var palletDescriptorToUpdate = Get(updatedPalletDescriptor.ID);
            palletDescriptorToUpdate?.Categories.Clear();
            if (palletDescriptorToUpdate == null)
            {
                throw new Exception("No Location exists with the id " + updatedPalletDescriptor.ID);
            }

            palletDescriptorToUpdate.Name = updatedPalletDescriptor.Name;

            base.UpdateDateUpdated(palletDescriptorToUpdate);

            db.PalletDescriptors.AddOrUpdate(p => p.ID, palletDescriptorToUpdate);
            db.SaveChanges();
            int idOfLocation = palletDescriptorToUpdate.ID;

            return idOfLocation;
        }
Пример #5
0
 private PalletDescriptorViewModel ConvertEntityToViewModel(PalletDescriptor entity)
 {
     return new PalletDescriptorViewModel
     {
         Categories = entity.Categories.ToList(),
         Name = entity.Name,
         ID = entity.ID,
     };
 }
Пример #6
0
 private PalletDescriptorDisplayViewModel.PalledDescriptorUpdateViewModel CreateUpdateViewModel(PalletDescriptor entity)
 {
     return new PalletDescriptorDisplayViewModel.PalledDescriptorUpdateViewModel
     {
         ID = entity.ID,
         Name = entity.Name,
         AllCategories = _categoryBll.GetDropDownDisplayForCategory()
     };
 }
Пример #7
0
        private PalletDescriptor ConvertUpdateViewModelToEntity(PalletDescriptorDisplayViewModel.PalledDescriptorUpdateViewModel viewModel)
        {
            var categoryDAL = new CategoryDAL();

            var entity = new PalletDescriptor
            {
                ID = viewModel.ID,
                Name = viewModel.Name,
                Categories = new List<Category>()
            };
            foreach (var selectedCategory in viewModel.SelectedCategories)
            {
                entity.Categories.Add(categoryDAL.Get(selectedCategory));
            }
            return entity;
        }