Esempio n. 1
0
        public int Create(CampaignDTO campaign)
        {
            var campaignEntity = _mapper.Map <Campaign>(campaign);

            campaignEntity.CampaignId = 0;
            _db.Add(campaignEntity);
            _db.SaveChanges();
            return(campaignEntity.CampaignId);
        }
Esempio n. 2
0
        public OperationResults Update(CampaignDTO campaign)
        {
            var entity = _db.Campaigns.Find(campaign.Id);

            if (entity == null)
            {
                return(OperationResults.NotFound);
            }

            _mapper.Map(campaign, entity);
            _db.Entry(entity).State = EntityState.Modified;

            try
            {
                _db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(OperationResults.Fail);
            }

            return(OperationResults.Success);
        }