Exemple #1
0
        /// <summary>
        /// Convert Subscription Object into Subscription Entity
        /// </summary>
        ///<param name="model">Subscription</param>
        ///<param name="SubscriptionEntity">DataAccess.Subscription</param>
        ///<returns>DataAccess.Subscription</returns>
        public static DataAccess.Subscription ToEntity(this SubscriptionViewModel model,
                                                       DataAccess.Subscription entity)
        {
            if (entity.Id == 0)
            {
                entity.CreatedUserId = model.SessionUserId;
            }
            else
            {
                entity.UpdatedUserId    = model.SessionUserId;
                entity.UpdatedTimestamp = DateTime.Now;
            }
            entity.QuoteDetailId = model.QuoteDetailId;
            entity.StartDate     = model.StartDate;
            entity.EndDate       = model.EndDate;

            return(entity);
        }
Exemple #2
0
        /// <summary>
        /// Convert Subscription Entity  into Subscription Object
        /// </summary>
        ///<param name="model">SubscriptionViewModel</param>
        ///<param name="SubscriptionEntity">DataAccess.Subscription</param>
        ///<returns>SubscriptionViewModel</returns>
        public static SubscriptionViewModel ToViewModel(
            this DataAccess.Subscription entity,
            SubscriptionViewModel model)
        {
            model.SessionUserId         = entity.CreatedUserId;
            model.Id                    = entity.Id;
            model.QuoteDetailId         = entity.QuoteDetailId;
            model.StartDate             = entity.StartDate;
            model.EndDate               = entity.EndDate;
            model.EndDateLongDate       = entity.EndDate.ToCustomLongDate();
            model.StartDateLongDate     = entity.StartDate.ToCustomLongDate();
            model.QuoteNo               = entity.QuoteDetail.Quote.QuoteNo;
            model.SubscriptionType      = entity.QuoteDetail.SubscriptionTypeRuleAudit.SubscriptionTypeRule.SubscriptionType.Name;
            model.FullName              = entity.QuoteDetail.Quote.QuoteUser.FirstName + " " + entity.QuoteDetail.Quote.QuoteUser.Surname;
            model.SubscriptionUserId    = entity.QuoteDetail.Quote.QuoteUserId;
            model.SubscriptionTypeModel = entity.QuoteDetail.SubscriptionTypeRuleAudit.SubscriptionTypeRule.SubscriptionType.ToViewModel(new SubscriptionTypeViewModel());

            return(model);
        }