Beispiel #1
0
        /// <summary>
        /// Saves the plan deployment attributes.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <param name="currentUserId">The current user identifier.</param>
        /// <returns> plan Events Id.</returns>
        public int?SavePlanDeploymentAttributes(Plans plan, int currentUserId)
        {
            var offerAttributes      = this.offerAttributesRepository.GetAllOfferAttributesByOfferId(plan.OfferId);
            var deploymentAttributes = offerAttributes.ToList().Where(s => s.Type.ToLower() == "deployment").ToList();

            foreach (var offerAttribute in deploymentAttributes)
            {
                PlanAttributeMapping attribute = new PlanAttributeMapping();
                var existingPlanAttribute      = this.plansRepository.GetPlanAttributeOnOfferAttributeId(offerAttribute.Id, plan.PlanGuid);
                if (existingPlanAttribute != null)
                {
                    attribute.OfferAttributeId = existingPlanAttribute.OfferAttributeId;
                    attribute.IsEnabled        = existingPlanAttribute.IsEnabled;
                    attribute.PlanId           = plan.PlanGuid;
                    attribute.UserId           = currentUserId;
                    attribute.PlanAttributeId  = existingPlanAttribute.PlanAttributeId;
                    attribute.CreateDate       = DateTime.Now;
                }
                else
                {
                    attribute.OfferAttributeId = offerAttribute.Id;
                    attribute.IsEnabled        = true;
                    attribute.PlanId           = plan.PlanGuid;
                    attribute.UserId           = currentUserId;
                    attribute.PlanAttributeId  = 0;
                    attribute.CreateDate       = DateTime.Now;
                }

                var planEventsId = this.plansRepository.SavePlanAttributes(attribute);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the plan attributes.
        /// </summary>
        /// <param name="planAttributes">The plan attributes.</param>
        /// <returns> Plan Attribute Id.</returns>
        public int?SavePlanAttributes(PlanAttributeMapping planAttributes)
        {
            if (planAttributes != null)
            {
                var existingPlanAttribute = this.context.PlanAttributeMapping.Where(s => s.PlanAttributeId ==
                                                                                    planAttributes.PlanAttributeId).FirstOrDefault();
                if (existingPlanAttribute != null)
                {
                    existingPlanAttribute.OfferAttributeId = planAttributes.OfferAttributeId;
                    existingPlanAttribute.IsEnabled        = planAttributes.IsEnabled;
                    existingPlanAttribute.PlanId           = planAttributes.PlanId;
                    existingPlanAttribute.UserId           = planAttributes.UserId;
                    existingPlanAttribute.PlanAttributeId  = planAttributes.PlanAttributeId;
                    existingPlanAttribute.CreateDate       = DateTime.Now;

                    this.context.PlanAttributeMapping.Update(existingPlanAttribute);
                    this.context.SaveChanges();
                    return(existingPlanAttribute.PlanAttributeId);
                }
                else
                {
                    this.context.PlanAttributeMapping.Add(planAttributes);
                    this.context.SaveChanges();
                    return(planAttributes.PlanAttributeId);
                }
            }

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Saves the plan attributes.
        /// </summary>
        /// <param name="planAttributes">The plan attributes.</param>
        /// <returns> Plan Event Id.</returns>
        public int?SavePlanAttributes(PlanAttributesModel planAttributes)
        {
            if (planAttributes != null)
            {
                PlanAttributeMapping attribute = new PlanAttributeMapping();
                attribute.OfferAttributeId = planAttributes.OfferAttributeId;
                attribute.IsEnabled        = planAttributes.IsEnabled;
                attribute.PlanId           = planAttributes.PlanId;
                attribute.UserId           = planAttributes.UserId;
                attribute.PlanAttributeId  = planAttributes.PlanAttributeId;
                attribute.CreateDate       = DateTime.Now;

                var planEventsId = this.plansRepository.SavePlanAttributes(attribute);
                return(planEventsId);
            }

            return(null);
        }