コード例 #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));
 }
コード例 #7
0
 public ActionResult <bool> Delete([FromRoute] DO.Location location)
 {
     return(Ok(_locationService.Delete(location)));
 }
コード例 #8
0
 public ActionResult <bool> Put([FromBody] DO.Location location)
 {
     return(Ok(_locationService.Insert(location)));
 }
コード例 #9
0
 public ActionResult <bool> Post([FromBody] DO.Location location)
 {
     return(Ok(_locationService.Update(location)));
 }