/// <summary> /// Gets the plan attributes. /// </summary> /// <param name="planGuId">The plan gu identifier.</param> /// <param name="offerId">The offer identifier.</param> /// <returns> List type="of Plan attributes.</returns> public IEnumerable <PlanAttributesModel> GetPlanAttributes(Guid planGuId, Guid offerId) { try { var offerAttributescCall = this.context.PlanAttributeOutput.FromSqlRaw("dbo.spGetOfferParameters {0}", planGuId); var offerAttributes = offerAttributescCall.ToList(); List <PlanAttributesModel> attributesList = new List <PlanAttributesModel>(); if (offerAttributes != null && offerAttributes.Count() > 0) { foreach (var offerAttribute in offerAttributes) { PlanAttributesModel planAttributes = new PlanAttributesModel(); planAttributes.PlanAttributeId = offerAttribute.PlanAttributeId; planAttributes.PlanId = offerAttribute.PlanId; planAttributes.OfferAttributeId = offerAttribute.OfferAttributeId; planAttributes.IsEnabled = offerAttribute.IsEnabled; planAttributes.DisplayName = offerAttribute.DisplayName; planAttributes.Type = offerAttribute.Type; attributesList.Add(planAttributes); } } return(attributesList); } catch (Exception ex) { throw ex; } }
/// <summary> /// Gets the plan detail by plan gu identifier. /// </summary> /// <param name="planGuId">The plan gu identifier.</param> /// <returns> Plans.</returns> public PlansModel GetPlanDetailByPlanGuId(Guid planGuId) { var existingPlan = this.plansRepository.GetByInternalReference(planGuId); var planAttributes = this.plansRepository.GetPlanAttributes(planGuId, existingPlan.OfferId); var planEvents = this.plansRepository.GetEventsByPlan(planGuId, existingPlan.OfferId); var offerDetails = this.offerRepository.GetOfferById(existingPlan.OfferId); PlansModel plan = new PlansModel { Id = existingPlan.Id, PlanId = existingPlan.PlanId, IsmeteringSupported = existingPlan.IsmeteringSupported, OfferID = existingPlan.OfferId, DisplayName = existingPlan.DisplayName, Description = existingPlan.Description, PlanGUID = existingPlan.PlanGuid, OfferName = offerDetails.OfferName, }; plan.PlanAttributes = new List <PlanAttributesModel>(); foreach (var attribute in planAttributes) { PlanAttributesModel planAttributesmodel = new PlanAttributesModel() { OfferAttributeId = attribute.OfferAttributeId, PlanAttributeId = attribute.PlanAttributeId, PlanId = existingPlan.PlanGuid, DisplayName = attribute.DisplayName, IsEnabled = attribute.IsEnabled, Type = attribute.Type, }; plan.PlanAttributes.Add(planAttributesmodel); } plan.PlanEvents = new List <PlanEventsModel>(); foreach (var events in planEvents) { PlanEventsModel planEventsModel = new PlanEventsModel() { Id = events.Id, PlanId = events.PlanId, Isactive = events.Isactive, SuccessStateEmails = events.SuccessStateEmails, FailureStateEmails = events.FailureStateEmails, EventName = events.EventsName, EventId = events.EventId, CopyToCustomer = events.CopyToCustomer, }; plan.PlanEvents.Add(planEventsModel); } return(plan); }
/// <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); }