示例#1
0
        public int Create(Location locationToCreate)
        {
            if (locationToCreate == null)
            {
                throw new Exception("The Location sent in for creation is null.");
            }

            base.UpdateDateAdded(locationToCreate);
            base.UpdateIsDeletedToFalse(locationToCreate);

            db.Locations.Add(locationToCreate);
            db.SaveChanges();
            int idOfLocation = locationToCreate.ID;

            return idOfLocation;
        }
示例#2
0
 public void Delete(Location locationToDelete)
 {
     Delete(locationToDelete.ID);
 }
示例#3
0
        public int Update(Location updatedLocation)
        {
            Location locationToUpdate = db.Locations.SingleOrDefault(i => i.ID == updatedLocation.ID && i.IsDeleted == false);

            if (locationToUpdate == null)
            {
                throw new Exception("No Location exists with the id " + updatedLocation.ID);
            }

            locationToUpdate.PrimaryLocation = updatedLocation.PrimaryLocation;
            locationToUpdate.SecondaryLocation = updatedLocation.SecondaryLocation;
            base.UpdateDateUpdated(locationToUpdate);

            db.Locations.AddOrUpdate(l => l.ID, locationToUpdate);
            db.SaveChanges();
            int idOfLocation = locationToUpdate.ID;

            return idOfLocation;
        }
示例#4
0
 public void Destroy(Location locationToDestroy)
 {
     Destroy(locationToDestroy.ID);
 }
示例#5
0
 private LocationDeleteViewModel ConvertEntityToLocationDeleteViewModel(Location model)
 {
     return new LocationDeleteViewModel
     {
         ID = model.ID,
         PrimaryLocation = model.PrimaryLocation,
         SecondaryLocation = model.SecondaryLocation,
     };
 }
示例#6
0
 private LocationDisplayViewModel ConvertEntityToLocationDisplayViewModel(Location model)
 {
     return new LocationDisplayViewModel
     {
         ID = model.ID,
         PrimaryLocation = model.PrimaryLocation,
         SecondaryLocation = model.SecondaryLocation,
         DateAdded = model.DateAdded,
         DateUpdated = model.DateUpdated
     };
 }