Пример #1
0
		protected override void PreListInsideTransaction(BusinessContext context)
		{
			base.PreListInsideTransaction(context);

			// OZ 2008-11-11 Fix Contact view for ibn partners
			ListRequest request = (ListRequest)context.Request;

			Guid orgUid, contactUid;

			// Check  

			if (PartnerUtil.GetClientInfo((int)DataContext.Current.CurrentUserId, out orgUid, out contactUid))
			{
				List<FilterElement> filters = new List<FilterElement>(request.Filters);

				// if (OrgUid!=null)   -> View all Contacts with OrgUid only 
				if (orgUid != Guid.Empty)
				{
					filters.Add(FilterElement.EqualElement("OrganizationId", orgUid));
				}
				// if (ContactUid!=null)   -> View Contact with ContactUid only 
				else if (contactUid != Guid.Empty)
				{
					filters.Add(FilterElement.EqualElement("PrimaryKeyId", contactUid));
				}
				// Nothing show
				else
				{
					filters.Add(FilterElement.IsNullElement("PrimaryKeyId"));
				}

				request.Filters = filters.ToArray();
			}
			//
		}
Пример #2
0
		/// <summary>
		/// Pres the create.
		/// </summary>
		/// <param name="context">The context.</param>
		protected override void PreCreate(BusinessContext context)
		{
			base.PreCreate(context);

			#region Fill Contact FullName = LastName FirstName MiddleName
			ContactEntity contact = (ContactEntity)context.Request.Target;

			if (string.IsNullOrEmpty(contact.FullName))
			{
				contact.FullName = contact.Properties.GetValue<string>("LastName", string.Empty) + " " + 
					contact.Properties.GetValue<string>("FirstName", string.Empty) + " " +
					contact.Properties.GetValue<string>("MiddleName", string.Empty);
			}

			// OZ 2008-11-11 Partner can create contacts only if his group has organization
			Guid orgUid, contactUid;
			if (PartnerUtil.GetClientInfo((int)DataContext.Current.CurrentUserId, out orgUid, out contactUid))
			{
				if (orgUid == Guid.Empty)
					throw new AccessDeniedException();
				else
					contact.OrganizationId = new PrimaryKeyId(orgUid);
			}
			//

			#endregion
		} 
Пример #3
0
		protected override void PreUpdate(BusinessContext context)
		{
			base.PreUpdate(context);

			ContactEntity contact = (ContactEntity)context.Request.Target;

			// OZ 2008-11-11 Partner can update contacts only if his group has organization
			Guid orgUid, contactUid;
			if (PartnerUtil.GetClientInfo((int)DataContext.Current.CurrentUserId, out orgUid, out contactUid))
			{
				if(orgUid == Guid.Empty && contactUid == Guid.Empty)
					throw new AccessDeniedException();

				if (orgUid != Guid.Empty)
					contact.OrganizationId = new PrimaryKeyId(orgUid); 
			}
			//
		}
Пример #4
0
        protected override void PreListInsideTransaction(BusinessContext context)
        {
            base.PreListInsideTransaction(context);

            // OZ 2008-11-11 Fix Organization view for ibn partners
            ListRequest request = (ListRequest)context.Request;

            Guid orgUid, contactUid;

            // Check  if (OrgUid!=null)   -> View Org with OrgUid only
            if (PartnerUtil.GetClientInfo((int)DataContext.Current.CurrentUserId, out orgUid, out contactUid))
            {
                List <FilterElement> filters = new List <FilterElement>(request.Filters);

                filters.Add(FilterElement.EqualElement("PrimaryKeyId", orgUid));

                request.Filters = filters.ToArray();
            }
            //
        }