コード例 #1
0
ファイル: Fix.cs プロジェクト: dovanduy/Library
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("User is not logged in");
            CashTrx paymentTrx = parm.Entity as CashTrx;

            paymentTrx.IsNullThrowException("Unable to unbox payment trx");


            if (paymentTrx.DocNumber == 0)
            {
                paymentTrx.DocNumber = GetNextDocNumber();
            }

            if (parm.Entity.Name.IsNullOrWhiteSpace())
            {
                parm.Entity.Name = UserName;
                parm.Entity.Name = parm.Entity.MakeUniqueName();
            }

            if (paymentTrx.PersonFromId.IsNullOrEmpty())
            {
                paymentTrx.PersonFromId = null;
            }

            paymentTrx.PersonToId.IsNullOrWhiteSpaceThrowException("You must declare who you are paying.");

            Person personTo = PersonBiz.Find(paymentTrx.PersonToId);

            personTo.IsNullThrowException("personTo");
            paymentTrx.PersonTo = personTo;

            base.Fix(parm);
        }
コード例 #2
0
ファイル: Index.cs プロジェクト: dovanduy/Library
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, ICommonWithId icommonWithId)
        {
            base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId);

            CashTrx cashTrx = icommonWithId as CashTrx;

            cashTrx.IsNullThrowException("Unable to unbox cashTrx");

            //get current user's PersonId first...
            Person person = UserBiz.GetPersonFor(UserId);

            if (person.IsNull())
            {
                indexItem.AllowDelete = false;
                indexItem.AllowEdit   = false;
            }
            else
            if (person.Id == cashTrx.PersonToId)
            {
                indexItem.AllowDelete = true;
                indexItem.AllowEdit   = false;
            }
            else
            {
                indexItem.AllowDelete = false;
                indexItem.AllowEdit   = false;
            }
        }