示例#1
0
        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);
        }
示例#2
0
        public void CreateCrews(CrewViewModel model)
        {
            var crew = new ScheduleCrew()
            {
                CrewID     = model.CrewID,
                ScheduleID = model.ScheduleID
            };

            _context.Add <ScheduleCrew>(crew);
            _context.SaveChanges();
        }