Beispiel #1
0
        public ModelResponse Delete(UserInfo user, long id, string reason)
        {
            try
            {
                //Authorization
                if (user == null)
                {
                    return(new ModelResponse(101));
                }
                if (!user.IsApproved || user.IsIndividual || user.OrgContactId == null)
                {
                    return(new ModelResponse(101));
                }

                var isAdmin = DalFactory.Singleton.DataService.IsAdmin(user.UserId);
                if (isAdmin && !Repo.IsInternal(id))
                {
                    return(new ModelResponse(101));
                }
                if (!isAdmin && !Repo.IsByOrgContact(id, (long)user.OrgContactId))
                {
                    return(new ModelResponse(101));
                }

                Repo.Delete(id, user.UserId, reason);
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(new ModelResponse(0));
        }
Beispiel #2
0
 public bool DeleteOpportunity(Opportunity opportunityToDelete)
 {
     try
     {
         _repository.Delete(opportunityToDelete);
     }
     catch
     {
         return(false);
     }
     return(true);
 }