Ejemplo n.º 1
0
        public CheckResult DeleteDispatch(DispatchModel model)
        {
            try
            {
                using (var db = DB.GetContext())
                {
                    var check = DispatchValidator.ValidateDelete(db, model);
                    if (check.Failed)
                    {
                        return(check);
                    }

                    DispatchRepository.DeleteDispatch(db, model);
                    db.SaveChanges();
                    return(check);
                }
            }
            catch (Exception ex)
            {
                return(new CheckResult(ex));
            }
        }
Ejemplo n.º 2
0
        public CheckResult SaveDispatch(DispatchModel model)
        {
            try
            {
                using (var db = DB.GetContext())
                {
                    var check = DispatchValidator.ValidateSave(db, model);
                    if (check.Failed)
                    {
                        return(check);
                    }

                    KeyBinder key = new KeyBinder();
                    DispatchRepository.SaveDispatch(db, key, model);
                    db.SaveChanges();
                    key.BindKeys();
                    return(check);
                }
            }
            catch (Exception ex)
            {
                return(new CheckResult(ex));
            }
        }