示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 bool ILocationService.Update(DO.Location location)
 {
     return(_locationDAL.Update(location));
 }
示例#5
0
 bool ILocationService.Insert(DO.Location location)
 {
     return(_locationDAL.Insert(location));
 }
示例#6
0
 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)));
 }