Exemplo n.º 1
0
        public Error InsertOrUpdateCustomerMarketing(CustomerMarketingModel marketing, UserModel user, string lockGuid)
        {
            var error = validateMarketingModel(marketing);

            if (!error.IsError)
            {
                // Check that the lock is still current
                if (!db.IsLockStillValid(typeof(MarketingGroupSubscription).ToString(), marketing.Id, lockGuid))
                {
                    error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "MarketingGroupId");
                }
                else
                {
                    MarketingGroupSubscription temp = null;
                    if (marketing.Id != 0)
                    {
                        temp = db.FindMarketingGroupSubscription(marketing.Id);
                    }
                    if (temp == null)
                    {
                        temp = new MarketingGroupSubscription();
                    }

                    MapToEntity(marketing, temp);

                    db.InsertOrUpdateMarketingGroupSubscription(temp);
                    marketing.Id = temp.Id;

                    db.Entry(temp).State = EntityState.Detached;     // Force EF to update FK's
                }
            }
            return(error);
        }
Exemplo n.º 2
0
        public CustomerMarketingModel MapToModel(MarketingGroupSubscription item)
        {
            var newItem = Mapper.Map <MarketingGroupSubscription, CustomerMarketingModel>(item);

            newItem.ContactName = (item.CustomerContact.ContactFirstname + " " + item.CustomerContact.ContactSurname).Trim();
            newItem.GroupName   = item.MarketingGroup.MarketingGroupName;
            return(newItem);
        }
Exemplo n.º 3
0
 public void MapToEntity(CustomerMarketingModel model, MarketingGroupSubscription entity)
 {
     Mapper.Map <CustomerMarketingModel, MarketingGroupSubscription>(model, entity);
 }