Пример #1
0
        public bool UpdateHotelMerchant(HotelMerchantCreateUpdateModel model)
        {
            var result = false;
            var entity = new HotelMerchants();
            var query  = _dbHotelContext.HotelMerchants.Where(x => x.Deleted == false && x.Id == model.Id);

            if (query.Count() > 0)
            {
                entity = query.FirstOrDefault();
            }
            else
            {
                return(result);
            }
            entity = _mapper.Map <HotelMerchantCreateUpdateModel, HotelMerchants>(model, entity);
            entity.LastModifiedBy   = _workContext.UserGuid;
            entity.LastModifiedDate = DateTime.Now;
            var status = _dbHotelContext.HotelMerchants.Update(entity);

            _dbHotelContext.SaveChanges();

            if (status.State == EntityState.Unchanged)
            {
                result = true;
            }

            return(result);
        }
Пример #2
0
        public bool CreateHotelMerchant(HotelMerchantCreateUpdateModel model)
        {
            var result = false;
            var entity = new HotelMerchants();

            entity                  = _mapper.Map <HotelMerchantCreateUpdateModel, HotelMerchants>(model, entity);
            entity.UniqueId         = UniqueIDHelper.GenerateRandomString(12);
            entity.CreatedBy        = _workContext.UserGuid;
            entity.CreatedDate      = DateTime.Now;
            entity.LastModifiedBy   = _workContext.UserGuid;
            entity.LastModifiedDate = DateTime.Now;
            var status = _dbHotelContext.HotelMerchants.Add(entity);

            _dbHotelContext.SaveChanges();

            if (status.State == EntityState.Unchanged)
            {
                result = true;
            }

            return(result);
        }