public string DeleteCrew(int id) { string msg = string.Empty; try { ScheduleCrew crew = _context.AsQueryable <ScheduleCrew>().Where(x => x.ID == id).FirstOrDefault(); if (crew != null) { _context.Remove <ScheduleCrew>(crew); _context.SaveChanges(); msg = "Crew deleted."; } } catch (Exception ex) { LogsViewModel error = new LogsViewModel() { ActionType = ActionType.Error.ToString(), Description = ex.Message + "\n" + ex.StackTrace, ModifiedBy = "Calendar Service Error : DeleteCrew()", DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm") }; new LogsService().Create(error); msg = "Unexpected error encountered. Please contact your system administrator."; } return(msg); }
public string Delete(int id) { //NOTE: Original Logic is to delete, but we change it to just deactivate the user. string msg = string.Empty; try { Data.Entities.Destination destination = _context.AsQueryable <Data.Entities.Destination>().Where(x => x.ID == id).FirstOrDefault(); if (destination != null) { _context.Remove <Data.Entities.Destination>(destination); _context.SaveChanges(); msg = "Destination deleted."; } } catch (Exception ex) { LogsViewModel error = new LogsViewModel() { ActionType = ActionType.Error.ToString(), Description = ex.Message + "\n" + ex.StackTrace, ModifiedBy = "Destination Service Error : Delete()", DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm") }; new LogsService().Create(error); msg = "Unexpected error encountered. Please contact your system administrator."; } return(msg); }