Example #1
0
        public bool UpdateHotelMerchantUser(HotelMerchantUserCreateUpdateModel model)
        {
            var result = false;
            var entity = new HotelMerchantUsers();
            var query  = _dbHotelContext.HotelMerchantUsers.Where(x => x.Deleted == false && x.Id == model.Id);

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

            _dbHotelContext.SaveChanges();

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

            return(result);
        }
Example #2
0
        public bool CreateHotelMerchantUser(HotelMerchantUserCreateUpdateModel model)
        {
            var result = false;
            var entity = new HotelMerchantUsers();

            entity                  = _mapper.Map <HotelMerchantUserCreateUpdateModel, HotelMerchantUsers>(model, entity);
            entity.CreatedBy        = _workContext.UserGuid;
            entity.CreatedDate      = DateTime.Now;
            entity.LastModifiedBy   = _workContext.UserGuid;
            entity.LastModifiedDate = DateTime.Now;
            var status = _dbHotelContext.HotelMerchantUsers.Add(entity);

            _dbHotelContext.SaveChanges();

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

            return(result);
        }