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); }
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); }
public void MapToEntity(CustomerMarketingModel model, MarketingGroupSubscription entity) { Mapper.Map <CustomerMarketingModel, MarketingGroupSubscription>(model, entity); }