예제 #1
0
        public void Save(ServiceRegisterViewModel model, Guid idAccount)
        {
            var service = ConvertService.FromServiceRegisterViewModel(model);

            service.IdAccount = idAccount;

            //Cuando es un nuevo servicio
            if (service.Id == Guid.Empty)
            {
                _serviceDao.InsertOrUpdate(service);
                _redisCache.flush(service.Id.ToString());
            }
            //Cuando es un servicio existente
            else
            {
                var exService = _serviceDao.GetOne(service.Id, idAccount);

                PropertyCopy.Copy(service, exService);

                service = null;

                //_serviceDao.Context.SaveChanges();
                //_serviceDao.InsertOrUpdate(exService);
                UpdateEntireService(exService, idAccount);
                foreach (var item in _serviceDao.Getcampaign(exService.Id))
                {
                    _redisCache.flush("CampaignServices:" + item.IdCampaign.ToString());
                }
            }

            //UpdateEntireService(service, idAccount);
        }