コード例 #1
0
ファイル: FamilyController.cs プロジェクト: vijaydairyf/bk
        public IHttpActionResult Delete(FamilyViewModel model)
        {
            if (!CanEditFamily(model.FamilyID))
            {
                return(BadRequest("You do not have rights to delete this family"));
            }

            bool logOut = false;

            using (bkContext context = new bkContext())
            {
                using (var tnx = context.Database.BeginTransaction())
                {
                    try
                    {
                        context.bk_DeleteFamily(model.FamilyID);
                        tnx.Commit();
                    }
                    catch
                    {
                        tnx.Rollback();
                        throw;
                    }

                    //make sure logged in member is still active on the system
                    logOut = !context.Members.Any(x => x.MemberID == LoggedInMemberId);
                }
            }

            return(Ok(logOut));
        }