Esempio n. 1
0
        public static Result Delete(PersonDto pPerson)
        {
            var _result = new Result();

            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pPerson)) {
                    try {
                        if (pPerson.PersonId == PersonRow.DefaultId)
                        {
                            throw new Exception("Cannot delete Default System Admin");
                        }

                        if (pPerson.ContactInfo != null)
                        {
                            ContactInfoManager.Delete(_db, pPerson.ContactInfo);
                        }

                        PersonManager.Delete(_db, pPerson.PersonId);
                        _tx.Commit();
                    }
                    catch (Exception _ex) {
                        _result.Success      = false;
                        _result.ErrorMessage = _ex.Message;
                        TimokLogger.Instance.LogRbr(LogSeverity.Error, "PersonController.Delete", string.Format("Exception:\r\n{0}", _ex));
                    }
                }
            }
            return(_result);
        }