bool ILocation.Delete(DO.Location location) { var _success = true; using (var context = new LocationContext()) { try { context.Location.Remove(location); context.SaveChanges(); } catch (Exception ex) { _success = false; Console.WriteLine(ex.Message); } } return(_success); }
bool ILocation.Insert(DO.Location location) { var _success = true; using (var context = new LocationContext()) { try { //Need to see if this insert adds duplicates to related foreignkey tables like locationtypemaster //If so, then use context.entry mode to add location context.Location.Add(location); context.SaveChanges(); } catch (Exception ex) { _success = false; Console.WriteLine(ex.Message); } } return(_success); }
DO.Location ILocation.Get(string name) { DO.Location _result = null; using (var context = new LocationContext()) { try { _result = context.Location .Where(p => p.Approved == true && p.Name.ToLower().Equals(name.ToLower())) .Include(p => p.LocationDetails) .ThenInclude(t => t.LocationTypeMaster) .Include(p => p.LocationActivitiesMapper) .FirstOrDefault(); } catch (Exception ex) { //Log Exception Console.WriteLine(ex.Message); } } return(_result); }
bool ILocationService.Update(DO.Location location) { return(_locationDAL.Update(location)); }
bool ILocationService.Insert(DO.Location location) { return(_locationDAL.Insert(location)); }
bool ILocationService.Delete(DO.Location location) { return(_locationDAL.Delete(location)); }
public ActionResult <bool> Delete([FromRoute] DO.Location location) { return(Ok(_locationService.Delete(location))); }
public ActionResult <bool> Put([FromBody] DO.Location location) { return(Ok(_locationService.Insert(location))); }
public ActionResult <bool> Post([FromBody] DO.Location location) { return(Ok(_locationService.Update(location))); }